You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This page leaves the reader with the impression that when working with const { data/trigger, error } = useSWR[Mutation], that SWR will catch any errors thrown inside the fetcher, prevent them from propagating further up by not (re-)throwing and set the error variable with the error caught. However, it is only if the option throwOnError: false has been set, that it will actually not (re-)throw.
I think that this should be made clear in the example (modified example): const { data, error } = useSWR('/api/user', fetcher, { throwOnError: false}) and that a point should be made of it - also showing an example for why we may not want to set the option. But being very explicit about that option.
The text was updated successfully, but these errors were encountered:
https://swr.vercel.app/docs/error-handling#status-code-and-error-object
This page leaves the reader with the impression that when working with
const { data/trigger, error } = useSWR[Mutation]
, that SWR will catch any errors thrown inside the fetcher, prevent them from propagating further up by not (re-)throwing and set theerror
variable with the error caught. However, it is only if the optionthrowOnError: false
has been set, that it will actually not (re-)throw.I think that this should be made clear in the example (modified example):
const { data, error } = useSWR('/api/user', fetcher, { throwOnError: false})
and that a point should be made of it - also showing an example for why we may not want to set the option. But being very explicit about that option.The text was updated successfully, but these errors were encountered: