合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
## axios 实例方法 * 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 实例方法的返回值都是 Promise,所以比较典型的使用方法如下: get 请求: ```js axios.get('http://localhost:9001/api/users', { params: { // 放在 URL 中的请求参数 id: 101 } }).then((response) => { // 请求成功的处理 }).catch((response) => { // 请求失败的处理 }) ``` post 请求: ```js axios.post('http://localhost:9001/api/login', { // 放在 body 中的请求参数 username: 'yungsem', password: '123456' }).then((response) => { // 请求成功的处理 }).catch((response) => { // 请求失败的处理 }) ``` ## response 结构 response 结构如下: ```js { // `data` is the response that was provided by the server data: {}, // `status` is the HTTP status code from the server response status: 200, // `statusText` is the HTTP status message from the server response statusText: 'OK', // `headers` the headers that the server responded with // All header names are lower cased headers: {}, // `config` is the config that was provided to `axios` for the request config: {}, // `request` is the request that generated this response // It is the last ClientRequest instance in node.js (in redirects) // and an XMLHttpRequest instance the browser request: {} } ```