0

You get the following error in axios.AxiosResponse.
How can I fix it?

error
Namespace 'axios' not found ts(2503)

import axios from 'axios';

Axios.interceptors.response.use(
  (response: axios.AxiosResponse) => {
    return Promise.resolve(response.data);
  },
  (error) => errorHandler(error),
);
1
  • cant understand Axios and (response: axios.AxiosResponse) in your code. here is the axios interceptors link npmjs.com/package/axios#interceptors Commented Nov 5, 2020 at 2:00

1 Answer 1

1

You need to import AxiosResponse from the axios package:

import axios, {AxiosResponse} from 'axios';

axios.interceptors.response.use(
  (response: AxiosResponse) => {
    return Promise.resolve(response.data);
  },
  (error) => errorHandler(error),
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.