useApi
The useAPI hook is used for invoking API calls and manage the response data accordingly. You should call onApi function to fetch and load the data.
Example Usage:
const fetchData = () => {
return fetch('<API URL>');
};
const { data, error, isLoading, onApi } = useApi(fetchData);Hook Argument
apiFunction
apiFunctionType |
|---|
Function of type: () => Promise<unknown> (Required) |
Hook Return Value
data
dataType | Default |
|---|---|
unknown (generic) | null |
error
errorType | Default |
|---|---|
String | Empty String |
isLoading
isLoadingType | Default |
|---|---|
boolean | false |
onApi
onApiType |
|---|
Function of type: () => Promise<unknown> |
Updated 23 days ago
What’s Next
