axios

来源:互联网 发布:改ip的软件 编辑:程序博客网 时间:2024/06/06 03:36

链接:https://www.npmjs.com/package/axios

安装:cnpm isntall axios;

支持情况:

Browser Matrix

get:

// Make a request for a user with a given ID 
axios.get('/user?ID=12345')
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });
 
// Optionally the request above could also be done as 
axios.get('/user', {
    params: {
      ID: 12345
    }
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });

post:
axios.post('/user', {
    firstName: 'Fred',
    lastName: 'Flintstone'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });
有如下几种方法:
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]])
配置文件:
https://www.npmjs.com/package/axios#request-config

原创粉丝点击