useNetworkError
The useNetworkError hook can be used to check if there was a network error. More Info...
By default, 404 status code is used.
Currently non-functional
The hook currently hardcodes the last HTTP status to 200 internally, so it always returns false. The intended behavior — described below — is to observe the HTTP status of the last request made by the application and report whether it matches (or, with loose, exceeds) one of the configured error codes.
import { useNetworkError } from '@archibald/client';
const isNetworkError = useNetworkError(PARAMETERS);
Parameters (optional)
object
| Property | Type | Description | Default |
|---|---|---|---|
| errorCodes | HttpCode[] | Array with status codes that should be used for checking if there was a network error. | Array with status code 404. |
| loose | boolean | When true (the default), the hook returns true when the last status code is strictly greater than any code in errorCodes. E.g. when the last status is 413 and errorCodes contains 404, the hook returns true; an exact 404 does not match in loose mode. When false, only exact matches in errorCodes count. | true |