10 examples of 'axios defaults' in JavaScript

Every line of 'axios defaults' 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
16get defaults() {
17 return this.axiosInstance.defaults;
18}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

140static get defaults() {
141 // Fetch environment defaults
142 const ENV_DEFAULTS = process.env.RPL_DEFAULTS
143 ? JSON.parse(process.env.RPL_DEFAULTS)
144 : {};
145
146 return { ...BUILTIN_DEFAULTS, ...ENV_DEFAULTS, ...USER_DEFAULTS };
147}
80options(url: string, config?: AxiosRequestConfig): AxiosPromise {
81 return this._requestMethodWithoutData('options', url, config);
82}
23function defaults( options, defaultOptions ) {
24
25 for ( var i in defaultOptions ) {
26 if ( !options.hasOwnProperty( i ) ) {
27 options[i] = defaultOptions[i];
28 }
29 }
30
31}
12function defaultXhr(settings) {
13 return new Promise((resolve, reject) => {
14 xhr(settings, (err, response, body) => {
15 if (response.statusCode === 200) {
16 resolve(body);
17 return;
18 }
19
20 if (!err) {
21 err = new Error();
22 err.statusCode = response.statusCode;
23 err.message = 'Status Code: ' + err.statusCode;
24 }
25
26 if (body) {
27 try {
28 const parsedBody = JSON.parse(body);
29 err.message = parsedBody.message || body;
30 } catch (e) {
31 err.message = body;
32 }
33 }
34
35 reject(err);
36 });
37 });
38}
74function _defaults (options) {
75 return defaultsDeep(options, {
76 json: {
77 pretty: process.env.NODE_ENV === 'development'
78 },
79 logger: {
80 enabled: process.env.NODE_ENV !== 'test',
81 format: process.env.NODE_ENV === 'development' ? 'dev' : 'common'
82 }
83 })
84}
13export function defaults<T>(val: T | undefined, def: T): T {
14 return typeof val === 'undefined' ? def : val;
15}
34public isAxios (): boolean {
35 return this.restClientType === RestClient.AXIOS
36}
107export function methodDefaults(options, bigOptions = {}) {
108 options = normalizeGetFunction(options)
109
110 options = cloneDeep(options || {})
111
112 // no debouncing for asyncData
113 delete options.debounce
114
115 // common
116 options = commonChanges(options)
117
118 return defaultsDeep(options, bigOptions, commonLocalDefaultObject, methodLocalDefaultObject)
119}
1module.exports = function defaults (config) {
2 var server
3
4 if (config.currentLogin) {
5 server = config.currentLogin.server
6 } else {
7 server = 'https://api.static.land'
8 }
9
10 return [{
11 name: 'server',
12 abbr: 's',
13 default: server,
14 help: 'The server that will host your site'
15 },
16 {
17 name: 'exclude',
18 abbr: 'e',
19 boolean: false,
20 help: 'list of files and directories you want to exclude from the deployment'
21 }]
22}

Related snippets