How to add axios interceptors in next.js

Viewed 1059

I have a fresh next.js project and I want to use axios interceptors in order to do some auth with JWT Tokens. Issue is im not sure where to add the below code from the axios docs

axios.interceptors.request.use(function (config) {
    // Do something before request is sent
console.log(config)
    return config;
  }, function (error) {
    // Do something with request error
    return Promise.reject(error);
  });

simply importing it into _app.tsx did not work.

0 Answers
Related