导航

vue-axios

Posted on 2018-04-13 11:11  小飞博客  阅读(129)  评论(0编辑  收藏  举报
  • 可以在node.js中使用
  • 提供了并发请求的接口
  • 支持Promise API

  简单使用:

1 axios({
2     method: 'GET',
3     url: url,
4 })
5 .then(res => {console.log(res)})
6 .catch(err => {console.log(err)})

并发请求:

 1 function getUserAccount() {
 2   return axios.get('/user/12345');
 3 }
 4 
 5 function getUserPermissions() {
 6   return axios.get('/user/12345/permissions');
 7 }
 8 
 9 axios.all([getUserAccount(), getUserPermissions()])
10   .then(axios.spread(function (acct, perms) {
11     // Both requests are now complete
12   }));