axios-react-hooks is a custom hooks library for consuming restful APIs using axios
there is two hooks in this library:
useAxiosGet
which can be used as below forGET
requests:
const {data, loading, refetch} = useAxiosGet(
{
endpoint: 'your/api/endpoint/here',
headers: {'header-name': 'header-value'}
}
);
useAxiosPost
which can be used as below forPOST
requests:
const [sendRequest, {data, loading}] = useAxiosPost(
{
endpoint: 'your/api/endpoint/here',
headers: {'header-name': 'header-value'}
}
);
...
sendRequest(body);
author: allaith aldababseh