React hooks to interact with an API from a stateless component using axios.
npm i react-api-hooks -s
useAPIOutput
React hook used to make a an API call using axios.
Allows you to pass an axios config object, for complete control of the request being sent.
Kind: global function
Returns: useAPIOutput
- output
Param | Type | Default | Description |
---|---|---|---|
url | string | URL that the API call is made to. | |
config | Object | {} | Axios config object passed to the axios.request method. |
Object
The object returned by the useAPI hook.
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
data | Object | undefined | The data attribute from the axios response. |
response | Object | undefined | The axios response. |
error | Object | undefined | The axios error object is an error occurs. |
isLoading | boolean | Indicates if their is a pending API call. |
setData | setDataFunc | Set the response data object. |
function
setData
property of useAPIOutput
Kind: global typedef
Param | Type | Description |
---|---|---|
newData | Array.<Object> | New data array that overwrites current data. |