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
I wanna add some customize filed in RequestConfig to control the HTTP request of Axios show loading gif or not.
But I found those customize filed is not found in the interceptor of Axios.
Here is my code.
interfaceRequestConfigextendsAxiosRequestConfig{hideLoading?: booleanloadingText?: stringwarnType?: stringhideWarn?: boolean}constservice=axios.create({})exportdefault{get: (url: string,data: object,config: RequestConfig)=>{let realConfig ={params: config, ...DEFAULT_CONFIG,config_flag: config};returnservice.get(url,realConfig)},}service.interceptors.request.use((request: RequestConfig)=>{leturl=request.url;if(!url)thrownewError('url is empty')if(!url.startsWith('/'))url='/'+url;console.time(request.baseURL+url)if(!request.params.hideLoading){// I can only get propert's value which defined in AxiosRequestConfig, // not in my customized ReuqestConfigstartLoading(request);}returnrequest},(err: any)=>{returnPromise.reject(err);});
In the interceptor's scope, the request doesn't contain any filed of RequestConfig.
But when I put my customized config in the filed of AxiosRequestConfig such as 'params'
It does works.
Does Axios ban the operate of customizing AxiosRequestConfig, such as add property, only return the pure properties of AxiosRequestConfig?
The text was updated successfully, but these errors were encountered:
zl7261
changed the title
Losing value when I customize AxiosRequestConfig
Losing cusomize property value when I add some customize property of AxiosRequestConfig
Oct 28, 2019
Axios version is ^0.19.0
I wanna add some customize filed in RequestConfig to control the HTTP request of Axios show loading gif or not.
But I found those customize filed is not found in the interceptor of Axios.
Here is my code.
In the interceptor's scope, the request doesn't contain any filed of RequestConfig.
But when I put my customized config in the filed of AxiosRequestConfig such as 'params'
It does works.
Does Axios ban the operate of customizing AxiosRequestConfig, such as add property, only return the pure properties of AxiosRequestConfig?
The text was updated successfully, but these errors were encountered: