1.2.0 • Published 3 years ago
axios-react-hooks v1.2.0
axios-react-hooks
axios-react-hooks is a custom hooks library for consuming restful APIs using axios
How to Use
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