Every line of 'axios config headers' 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.
329 function mergeHeaders(config) { 330 var defHeaders = defaults.headers, 331 reqHeaders = extend({}, config.headers), 332 defHeaderName, lowercaseDefHeaderName, reqHeaderName; 333 334 defHeaders = extend({}, defHeaders.common, defHeaders[lowercase(config.method)]); 335 336 // execute if header value is function 337 execHeaders(defHeaders); 338 execHeaders(reqHeaders); 339 340 // using for-in instead of forEach to avoid unecessary iteration after header has been found 341 defaultHeadersIteration: 342 for (defHeaderName in defHeaders) { 343 lowercaseDefHeaderName = lowercase(defHeaderName); 344 345 for (reqHeaderName in reqHeaders) { 346 if (lowercase(reqHeaderName) === lowercaseDefHeaderName) { 347 continue defaultHeadersIteration; 348 } 349 } 350 351 reqHeaders[defHeaderName] = defHeaders[defHeaderName]; 352 } 353 354 return reqHeaders; 355 356 function execHeaders(headers) { 357 var headerContent; 358 359 forEach(headers, function(headerFn, header) { 360 if (isFunction(headerFn)) { 361 headerContent = headerFn(); 362 if (headerContent != null) { 363 headers[header] = headerContent; 364 } else { 365 delete headers[header]; 366 } 367 } 368 }); 369 } 370 }
34 public isAxios (): boolean { 35 return this.restClientType === RestClient.AXIOS 36 }
10 function request(config) { 11 var userToken = $cookies.get('xrAuthCookie'); 12 13 if (typeof userToken !== 'undefined') { 14 config.headers['Authorization'] = 'Bearer ' + userToken; 15 } 16 17 return config; 18 }
13 function Axios(instanceConfig) { 14 this.defaults = instanceConfig; 15 this.interceptors = { 16 request: new InterceptorManager(), 17 response: new InterceptorManager() 18 }; 19 }
12 function AddAuthorizationToHeader(config) { 13 var token = OAuthAPI.getToken(); 14 15 if (config["headers"] === null || config["headers"] === undefined) 16 config["headers"] = {}; 17 18 if (token !== null && token !== undefined) 19 config["headers"] = Object.assign(config["headers"], { 20 Authorization: "Bearer " + token 21 }); 22 23 return config; 24 }
53 function use(axios, config) { 54 if (!isAxiosInstance(axios)) { 55 throw new Error('Redel must init with an axios instance!') 56 } 57 if (this._axios) { 58 // if developer try to call `use` twice or more 59 // we should eject all plugins before init the Redel instance again, 60 // this will ensure that we avoid memory leak or mismatch 61 ejectAll.call(this) 62 } 63 this._axios = axios 64 if (config && typeof config === 'object' && !Array.isArray(config)) { 65 Object.keys(config).forEach((key) => { 66 if (AuthorizedPlugins[key]) { 67 logger.log(` ${key} Plugin was sign`) 68 _addPlugin.call(this, key) 69 } 70 }) 71 } else { 72 throw new Error('Redel: try to initialize the "use" function with wrong config type') 73 } 74 }
44 export function request(config: RequestConfig) { 45 config.baseURL = `//${process.env.RIDI_PAY_API_SERVER_HOST}`; 46 config.withCredentials = true; 47 config.headers = { 48 ...config.headers, 49 'Content-Type': 'application/json' 50 }; 51 // Workaround to set Content-Type: https://github.com/axios/axios/issues/86 52 config.data = config.data || {}; 53 return axios(config); 54 }
80 options(url: string, config?: AxiosRequestConfig): AxiosPromise { 81 return this._requestMethodWithoutData('options', url, config); 82 }
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 }
16 get defaults() { 17 return this.axiosInstance.defaults; 18 }