When you need to make an API call, you can use this hook to benefit from handling your loading and error logic in one place. The API hook will update whenever one of the parameters passed has changed.
The useAPI hook returns an object with two properties: loading and data. You can use the loading value to handle the loading state in the parent object. Data will be returned when the API response is returned.
The hook will automatically forward any errors to the error handler in the view context.