Skip to content

Latest commit

 

History

History
28 lines (25 loc) · 648 Bytes

README.md

File metadata and controls

28 lines (25 loc) · 648 Bytes

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 for GET requests:
const {data, loading, refetch} = useAxiosGet(
  {
    endpoint: 'your/api/endpoint/here',
    headers: {'header-name': 'header-value'}
  }
);
  • useAxiosPost which can be used as below for POST requests:
const [sendRequest, {data, loading}] = useAxiosPost(
  {
    endpoint: 'your/api/endpoint/here', 
    headers: {'header-name': 'header-value'}
  }
);
...
sendRequest(body);

author: allaith aldababseh