本文整理汇总了TypeScript中axios.AxiosInstance.create方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AxiosInstance.create方法的具体用法?TypeScript AxiosInstance.create怎么用?TypeScript AxiosInstance.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类axios.AxiosInstance
的用法示例。
在下文中一共展示了AxiosInstance.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(url: string, private readonly log: LogService) {
this.axios = axios.create({
headers: { 'kbn-xsrf': 'x-pack/ftr/services/features' },
baseURL: url,
maxRedirects: 0,
validateStatus: () => true, // we'll handle our own statusCodes and throw informative errors
});
}
示例2: constructor
constructor(url: string, defaults: IncomingWebhookDefaultArguments = {}) {
if (url === undefined) {
throw new Error('Incoming webhook URL is required');
}
this.url = url;
this.defaults = defaults;
this.axios = axios.create({
baseURL: url,
httpAgent: defaults.agent,
httpsAgent: defaults.agent,
maxRedirects: 0,
proxy: false,
headers: {
'User-Agent': getUserAgent(),
},
});
delete this.defaults.agent;
}