How to detect cancelled error request in Nuxt Axios plugin globally?

Viewed 23

"@nuxtjs/axios": "5.13.6"

I want to get custom error handler to cancelled requests, but isCancel is falsy everytime. How to handle it correctly?

axios plugin:

$axios.onError(async (error) => {
  if ($axios.isCancel(error)) { return Promise.reject(error.response); }
  ...
});

I tried to add token to onRequest too:

$axios.onRequest(async (config) => {
  const source = $axios.CancelToken.source();
  config.cancelToken = source.token;

  return config;
})
0 Answers
Related