- 可以在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 }));