Open aquibbaig opened 3 years ago
Also, a good way to achieve this is by conditionally checking for response.ok
, but when I return from a request.post()
, it should return a response object but it returns only the body of the response.
For example:
(1) callee
const response = await request.post(ep, options);
console.log(response)
// returns only the body as {"message": "Ilorem ipsum"}, cannot find the status, statusText and other parameters.
(2) interceptor
request.interceptors.response.use(response => {
console.log(response)
// prints out the actual response object with all the parameters
return response;
// returns to the callee in (1) but logs only the body, not parameters
})
We have a default error handler as follows.
We need to skip the error handler for special cases and handle exceptions ourselves. It is possible with "plugin-request" provided by umi, is it supported in "umi-request" by any means?