TypeError: Cannot read property 'cancelToken' of undefined

See original GitHub issue
const middlewareConfig = {
    interceptors: {
        request: [
            {
                success: function ({getState, dispatch, getSourceAction}, req) {
                    console.error(1, req);
                },
                error: function ({getState, dispatch, getSourceAction}, error) {
                    console.error(2, error);
                }
            }
        ],
        response: [
            {
                success: function ({getState, dispatch, getSourceAction}, req) {
                    console.error(3, req);
                },
                error: function ({getState, dispatch, getSourceAction}, error) {
                    console.error(4, error);
                }
            }
        ]
    }
};
const middleware = [
    multiClientMiddleware(clients, middlewareConfig),
    routerMiddleware(history)
];

export default createStore(
    reducers,
    composeEnhancers(
        applyMiddleware(...middleware)
    )
)
TypeError: Cannot read property 'cancelToken' of undefined
    at throwIfCancellationRequested (index.js?v=:72)
    at dispatchRequest (index.js?v=:84)
screen shot 2018-04-23 at 3 17 55 pm screen shot 2018-04-23 at 3 19 33 pm screen shot 2018-04-23 at 3 21 42 pm screen shot 2018-04-23 at 3 23 48 pm

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:11

github_iconTop GitHub Comments

239reactions
givingwucommented, Aug 7, 2018

Look the Comments

axios.interceptors.request.use(function(config) {
  console.log('request => config ====================================');
  console.log(config);
  console.log('request => config ====================================');

  // if u add new Chainable promise or other interceptor
  // You have to return `config` inside of a rquest
  // otherwise u will get a very confusing error
  // and spend sometime to debug it.
  return config;
}, function(error) {
  return Promise.reject(error);
});
42reactions
Wuruiyangcommented, Aug 20, 2019

If you write API.interceptors.request.use(config => { console.log(config) return config }) not forget return config

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is cancelToken by axios and how I fix it? - Stack Overflow
TypeError : Cannot read properties of undefined (reading 'cancelToken') at throwIfCancellationRequested (dispatchRequest.js:12:1) at ...
Read more >
Cannot read property 'cancelToken' of undefined - Bitbucket
I need to authenticate first using Chrome and YubiKey/OTP and only then the API requests will be forwarded to Jira or BB. Now,...
Read more >
TypeError: Cannot read property 'cancelToken' of undefined
const middlewareConfig = { interceptors: { request: [ { success: function ({getState, dispatch, getSourceAction}, req) { console.error(1, ...
Read more >
Cannot read property 'cancelToken' of undefined“_滑德友的博客
Cannot read property 'cancelToken' of undefined“. axios拦截请求时忘记返回config了 // 拦截请求 httpService.interceptors.request.use(config ...
Read more >
Axios Interceptor Model And Pitfalls - DEV Community ‍ ‍
ts-node --files main.ts interceptor2 handle error caller handle error TypeError: Cannot read property 'cancelToken' of undefined.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found