Closed stefensuhat closed 7 years ago
I think your issue might be with your params to your interceptors.
https://github.com/svrcekmichal/redux-axios-middleware#middleware-options
Try the following, not the first param.
function interceptorResponse({ dispatch, getState, getAction }, response) {
console.log(dispatch);
console.log(response);
console.log(error);
}
@nmaves thanks for you answer. actually your answer is no difference with mine except you destructuring the variables at top. Success response will console out. But if the response is an error it won't console it out.
Are you setting returnRejectedPromiseOnError to true?
@stefensuhat by default interceptors are handling only success response. To handle also error response you must not add it as function, but as object with keys error
/success
export const clientOptions = {
interceptors: {
response: [{ success: interceptorSuccessResponse, error: interceptorErrorResponse }],
},
};
@svrcekmichal do you think read me file has to be updated with description of how set interceptors? In current read.me doesn't contains information on how to set "error" interceptors properly. I spent some time to debug middleware to find out how set it. thanks. it's really nice middleware =)
@Palatnyi I believed it was mentioned somewhere. If someone can make PR, it would be great, if not I'll look at this later next week. Thanks
@svrcekmichal perfecto! you saved my entire life 💃
We have updated the readme in #53. Thank you @Palatnyi
@nmaves Thanks for merging my commit. This is my debut in in open source =)
Hi, Thanks for this great package!. Need ask or maybe I doing it wrong.
I'm trying to setup the axiosmiddleware with interceptor. The interceptor request is working properly but the interceptor response not working.
here is my code:
my question:
// Add a response interceptor axios.interceptors.response.use(function (response) { // Do something with response data return response; }, function (error) { // Do something with response error return Promise.reject(error); });