Handling the Error
info
- If
fetch
fails (e.g. no internet, server down), the code will jump tocatch
and print the error message. - You'll want see a helpful message like:
Something went wrong: TypeError: Failed to fetch
[!TIP]
console.error('Something went wrong:', error);