24/7/12总结

axios

Axios 是一个基于 promise 网络请求库,作用于node.js 和浏览器中。 它是 isomorphic 的(即同一套代码可以运行在浏览器和node.js中)。在服务端它使用原生 node.js http 模块, 而在客户端 (浏览端) 则使用 XMLHttpRequests。

get请求:

javascript 复制代码
 <script>
    function register(){
        axios({
            method:'GET',
            url:'http://localhost:8080/java_web_final2_war_exploded/demo11'
        }).then(
            response => console.log(response),
            error => console.log(error)
        )
    }
 </script>

post请求:

javascript 复制代码
axios.post('http://localhost:8080/java_web_final2_war_exploded/demo11', {
    firstName: 'Fred',
    lastName: 'Flintstone'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });

多并发:

javascript 复制代码
function getUserAccount() {
  return axios.get('/user/12345');
}

function getUserPermissions() {
  return axios.get('/user/12345/permissions');
}

const [acct, perm] = await Promise.all([getUserAccount(), getUserPermissions()]);

// OR

Promise.all([getUserAccount(), getUserPermissions()])
  .then(function ([acct, perm]) {
    // ...
  });

HTTP

相关推荐
LJ小番茄8 分钟前
Vue 常见的几种通信方式(总结)
前端·javascript·vue.js·html
黑狼传说12 分钟前
前端项目优化:极致最优 vs 相对最优 —— 深入探索与实践
前端·性能优化
장숙혜18 分钟前
前端-CDN的理解及CDN一些使用平台
前端
m0_6312704023 分钟前
高级c语言(五)
c语言·开发语言
2401_8582861129 分钟前
53.【C语言】 字符函数和字符串函数(strcmp函数)
c语言·开发语言
程序猿练习生1 小时前
C++速通LeetCode中等第5题-无重复字符的最长字串
开发语言·c++·leetcode
2401_858120261 小时前
MATLAB中的无线通信系统部署和优化工具有哪些
开发语言·matlab
MATLAB滤波1 小时前
【PSINS】基于PSINS工具箱的EKF+UKF对比程序|三维定位|组合导航|MATLAB
开发语言·matlab
2401_858120531 小时前
MATLAB在嵌入式系统设计中的最佳实践
开发语言·matlab
蓝裕安1 小时前
伪工厂模式制造敌人
开发语言·unity·游戏引擎