You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sensible interceptors must return either an AxiosRequestConfig or an AxiosResponse or else they break other interceptors and Axios internal logic.
The PR is to required interceptor to return data, but it ends up not only require to return data, but require to return axios response type data, thus it limited the usage of interceptors, just wanna to confirm whether this is in purpose or it is a bug
To Reproduce
// Example code here// In Typescript, write interceptor like this:api.interceptors.response.use((response: AxiosResponse): unknown=>response.data)// Type 'unknown' is not assignable to type 'AxiosResponse<any, any> | Promise<AxiosResponse<any, any>>'.
Expected behavior
Expected code running without type error
Environment
Axios Version [1.1.2]
Adapter [e.g. XHR/HTTP]
The text was updated successfully, but these errors were encountered:
interfaceCustomAxiosResponseData<T=unknown>{code: stringdata: Tmessage: string}ai.interceptors.response.use((response)=>{const{ data }: {data: CustomAxiosResponseData}=responsereturndata},(error)=>{returnPromise.reject(error)})
When I switch to using version 0.27.2, it works well.
Is this right? Or is there any way to change the returned value type in a response interceptor at version 1.1.3?
Describe the bug
Here is how we use interceptor to extract
data
fromresponse
rather than duplicate the same logic.then((res) => res.data)
everywhere in the projecthowever because of the new changes from #4874,
The PR is to required interceptor to return data, but it ends up not only require to return data, but require to return axios response type data, thus it limited the usage of interceptors, just wanna to confirm whether this is in purpose or it is a bug
To Reproduce
Expected behavior
Expected code running without type error
Environment
The text was updated successfully, but these errors were encountered: