Whenever I execute this query, I get this error:
but it doesn't seem to affect anything.Why does this error occur?
Whenever I execute this query, I get this error:
but it doesn't seem to affect anything.Why does this error occur?
Hi,
Fetch promises only reject with a TypeError when a network error occurs. Since 4xx and 5xx responses aren't network errors, there's nothing to catch. You'll need to throw an error yourself to use Promise#catch.
A fetch Response conveniently supplies an ok , which tells you whether the request succeeded. Something like this should do the trick:
fetch(url).then((response) => { if (response.ok) { return response.json(); } throw new Error('Something went wrong');}).then((responseJson) => { // Do something with the response}).catch((error) => { console.log(error)});I can see that you are using Neon database. For specific Neon related implementation, you can also reach out to their Support team.