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
Similar to #14, response events should be available on the client/resource modules. For example:
API=newResource(...)// Listen for all responsesAPI.on('response',response=>{console.log(`Recevied (${response.status}) ${response.responseText}`)})// Listen for 401 response status API.on('401',response=>{console.warn('unauthorized access')})// Listen for 400 level status codesAPI.on('4XX',response=>{console.warn(`Recevied (${response.status}) ${response.responseText}`)})
In most cases, responses will be handled directly by the request caller. Events allow global listeners to log responses, trigger additional response handlers, etc. For instance, many people are used to the axios HTTP library, which throws an error on 4XX responses. 4XX are a successful HTTP response indicating there was a some sort of network or api related problem, such as a 401 indicating a user can contact and endpoint but isn't allowed to do so. This library does not consider an HTTP response status code to be a JavaScript error, but it can still be useful to throw an application error when one of these types of responses occurs.
This can also be used to identify problems, modify the client/resource instance, and retry a request automatically (such as renewing an access token before retrying a failed request).
Finally, these events can be very useful for logging.
The text was updated successfully, but these errors were encountered:
Similar to #14, response events should be available on the client/resource modules. For example:
In most cases, responses will be handled directly by the request caller. Events allow global listeners to log responses, trigger additional response handlers, etc. For instance, many people are used to the axios HTTP library, which throws an error on 4XX responses.
4XX
are a successful HTTP response indicating there was a some sort of network or api related problem, such as a401
indicating a user can contact and endpoint but isn't allowed to do so. This library does not consider an HTTP response status code to be a JavaScript error, but it can still be useful to throw an application error when one of these types of responses occurs.This can also be used to identify problems, modify the client/resource instance, and retry a request automatically (such as renewing an access token before retrying a failed request).
Finally, these events can be very useful for logging.
The text was updated successfully, but these errors were encountered: