This is the custom react hook which you can use to call the api and it will return the data,error(if any),loading status.
npm install react-custom-fetch-hook


React hook for conveniently use Fetch API. It will take url and the extra header if needed.
``javascript
import useFetch from 'react-custom-fetch-hook'
function CustomHook() {
const {data,loading} = useFetch('https://quotable.io/quotes',{})
if(loading){
return
{result.content}
`
useFetch accepts the same arguments as fetch function.
Install it with npm:
``
npm i react-custom-fetch-hook --save
The useFetch hook returns an error field at any fetch exception. error
The field extends Errorstatus
and has and statusText fields equal to Response.
`javascript
function CustomHook() {
const {data,loading ,error } = useFetch("https://quotable.io/quotes");
if (error) {
return
Code: ${error.status}
Message: ${error.statusText}
``