I have a problem with https://github.com/svrcekmichal/redux-axios-middleware .
I want to set an interceptor response (error). But he cannot successfully configure it.
Here is my code:
function interceptorResponse({ dispatch, getState, getAction }, response) { console.log(response); } export const client = axios.create({ baseURL: API_URL, headers: { Accept: 'application/json', }, }); export const clientOptions = { interceptors: { request: [interceptorRequest], response: [interceptorResponse], }, };
console.log(response) answers only if the response is 200 . How can I configure it to accept an error response?
I tried installing it like this:
function interceptorResponse({ dispatch, getState, getAction }) { return response => response.data, (error) => { const meta = error.response.data.meta; const { code, status } = meta; console.log(meta); }; }
but still not show anything.
Any solution?
source share