Every line of 'axiosinstance' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
13 function Axios(instanceConfig) { 14 this.defaults = instanceConfig; 15 this.interceptors = { 16 request: new InterceptorManager(), 17 response: new InterceptorManager() 18 }; 19 }
39 function isAxiosInstance(axios) { 40 return axios && typeof axios.interceptors === 'object' 41 }
61 get axiosRef(): AxiosInstance { 62 return this.instance; 63 }
15 function createBaseInstance() { 16 const instance = axios.create({ 17 baseURL: BASE_URL, 18 }) 19 20 instance.interceptors.response.use(handleResponse, handleError) 21 return instance 22 }
33 function axiosWithCache(...arg) { 34 if(arg.length === 1 && (arg[0].method === 'get' || arg[0].method === undefined)) { 35 return requestWithCacheCheck(arg[0], instance, ...arg) 36 }else { 37 return instance(...arg) 38 } 39 }
34 public isAxios (): boolean { 35 return this.restClientType === RestClient.AXIOS 36 }
16 get defaults() { 17 return this.axiosInstance.defaults; 18 }
21 setHttp(axios) { 22 this.unsetHttp(); 23 24 if (axios) { 25 this.http = axios; 26 this.originalAdapter = axios.defaults.adapter; 27 axios.defaults.adapter = config => this.adapter(config); 28 } 29 return this; 30 }
9 constructor (private _url: string, private _config: AxiosRequestConfig) { 10 this.axiosInstance = Axios.create({ 11 baseURL: _url, 12 timeout: 30000 13 }) 14 }
3 function wrapAxios(axios, options = {}) { 4 const {tracer} = options; 5 const instrumentation = new Instrumentation.HttpClient(options); 6 const zipkinRecordRequest = config => tracer.scoped(() => { 7 const newConfig = instrumentation.recordRequest( 8 config, 9 config.url, 10 config.method 11 ); 12 newConfig.traceId = tracer.id; 13 return newConfig; 14 }); 15 const zipkinRecordResponse = res => tracer.scoped(() => { 16 instrumentation.recordResponse(res.config.traceId, res.status); 17 return res; 18 }); 19 const zipkinRecordError = error => tracer.scoped(() => { 20 if (error.config) { 21 const {traceId} = error.config; 22 if (error.response) { 23 instrumentation.recordResponse(traceId, error.response.status); 24 } else { 25 instrumentation.recordError(traceId, error); 26 } 27 } // otherwise the error preceded the request interceptor 28 return Promise.reject(error); 29 }); 30 let axiosInstance = axios; 31 if (axios.create) { 32 axiosInstance = axios.create(); 33 } 34 axiosInstance.interceptors.request.use(zipkinRecordRequest, zipkinRecordError); 35 axiosInstance.interceptors.response.use(zipkinRecordResponse, zipkinRecordError); 36 return axiosInstance; 37 }