Skip to content

Instantly share code, notes, and snippets.

Last active Feb 20, 2020
What would you like to do?
Is it a fetch network error? (for the purpose of retrying on failure).
github/fetch: TypeError: Network request failed
Chrome: TypeError: Failed to fetch
Firefox: TypeError: NetworkError when attempting to fetch resource.
Safari: TypeError: The Internet connection appears to be offline.
const isNetworkError = e =>
/The Internet connection appears to be offline|Failed to fetch|Network request failed|NetworkError when attempting to fetch resource|The network connection was lost/.test(
) ||
e.statusCode === 502 ||
e.statusCode === 504;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment