I tired to add response Interceptor, and then I got a type error. #5660
Unanswered
JohnYang02182
asked this question in
Q&A
Replies: 1 comment
-
You need to return a axios.interceptors.response.use((res: AxiosResponse) => {
if (res.status === 200) {
if (res.data.code !== '993') {
return Promise.resolve(res)
} else {
console.log('overtime')
// ^^^^^^^^^^^^^^
}
} else {
return Promise.reject(res)
}
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I tried to add a response Interceptor like below
And then I got the error messages--
"The argument of type '(res: AxiosResponse) => Promise<AxiosResponse<any, any>> | undefined' cannot be assigned to the parameter of type '(value: AxiosResponse<any, any>) => AxiosResponse<any, any> | Promise<AxiosResponse<any, any>>'."
My version:
typescript : "4.9.3"
axios: "1.3.4"
I would appreciate it if someone could tell me what to do, or if something I missed.
Beta Was this translation helpful? Give feedback.
All reactions