This package offers 2 different parts, a
Auth (React Functional Component) and a
Client (Util Class). The
Auth component places a authentication wrapper around the whole app which exposes a user state to all components of the app via the Context api. The
Client could be used to wrapper you API call and return to you an object or throw an error if there is any.
You just need to wrap your component or entire application with the
<Auth> tag to use the information from this component in any place through the context API.
This client wraps API requests with the user's auth token and transforms the response. If the response is a JSON string, it will return the object generated from the JSON.
The client transforms errors, converting them to a FailedAuthClientResponseError object.
The error seen in
.catch(e) is the message from the server, which can also be accessed using
e.message. However, some APIs have more information in the response body. You can check the entire response from the server using
e.response, a Response object.