elbywan / wretch

A tiny wrapper built around fetch with an intuitive syntax. :candy:
MIT License
4.83k stars 98 forks source link

handling other errors #29

Closed kkesley closed 6 years ago

kkesley commented 6 years ago

Hello, Can wretch handle all other errors beside the one that I specify?

e.g.

wretch().url(...).post(....)
.unauthorized(_=>{...})
.internalError(_=>{...})
.allOtherErrors(_=>{...})
elbywan commented 6 years ago

@kkesley Hi!

Yes, you can use the generic .catch method since wretch returns a standard Promise:

wretch().url(...).post(....)
.unauthorized(_ => { ... })
.internalError(_ => { ... })
// ...
.res(_ => { ... })
// ...
.catch(otherError => { ... })
kkesley commented 6 years ago

Thank you! What a great library!