Axios 实例

创建实例

¥Creating an instance

你可以使用自定义配置创建一个新的 axios 实例。

¥You can create a new instance of axios with a custom config.

axios.create([config])
const instance = axios.create({
  baseURL: 'https://some-domain.com/api/',
  timeout: 1000,
  headers: {'X-Custom-Header': 'foobar'}
});

实例方法

¥Instance methods

下面列出了可用的实例方法。指定的配置将与实例配置合并。

¥The available instance methods are listed below. The specified config will be merged with the instance config.

axios#request(config)
axios#get(url[, config])
axios#delete(url[, config])
axios#head(url[, config])
axios#options(url[, config])
axios#post(url[, data[, config]])
axios#put(url[, data[, config]])
axios#patch(url[, data[, config]])
axios#getUri([config])