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
Make sure useFetch rejects with an Error type. (#114)
* Make sure useFetch rejects with an Error type.
Previously, a non-ok http response would reject with the response
object. It's better for rejections to be of type Error so that the
full stack trace information is available; plus, the TypeScript type
definition assumes that the error object is always instanceof Error.
Instead, failed responses reject with a FetchError, with the
underlying Response object available as error.response.
This is a backward-incompatible change: users who expected `error` to
be of type Response now have to refer to `error.response` instead.
* FetchError: add status code to the error message.
* Define FetchError as a class, not just an interface.
This is necessary for TypeScript code to be permitted to use
FetchError as a value at runtime, e.g. to perform an `instanceof
FetchError` check.
0 commit comments