Swr: Error handling

Created on 17 Nov 2019  路  2Comments  路  Source: vercel/swr

What's the best way to handler errors from API calls via fetch or axios handlers while creating a Global Configuration?

documentation

Most helpful comment

@sergiodxa Yes that works! Thank you.
If anyone needs a reference, I have created a Sandbox for that: Error handling with SWR global fetch

All 2 comments

What I did is my fetcher check if the error is 4xx and throw an error. That way I got them as the key error returned by useSWR

@sergiodxa Yes that works! Thank you.
If anyone needs a reference, I have created a Sandbox for that: Error handling with SWR global fetch

Was this page helpful?
0 / 5 - 0 ratings

Related issues

polc picture polc  路  3Comments

bcomnes picture bcomnes  路  3Comments

DoT214 picture DoT214  路  4Comments

Ephys picture Ephys  路  3Comments

alexanderbluhm picture alexanderbluhm  路  3Comments