DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Discussion on: Simplify JavaScript Promises

Collapse
bushblade profile image
Will Adams

Just wanted to add in that fetch doesn't throw errors or reject so .catch won't fire there. You need to throw your own errors with fetch.

Collapse
aminnairi profile image
Amin

From the documentation, it is stated that

A fetch() promise only rejects when a network error is encountered

So I guess this is the case when the fetch method can throw an error.

Thread Thread
bushblade profile image
Will Adams • Edited on

Yeah you'll want to throw your own errors if you're using fetch and want to catch any errors. Something to be aware of otherwise most of your 'errors' will end up in your .then