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

相关推荐
记得早睡~1 分钟前
leetcode150-逆波兰表达式求值
javascript·算法·leetcode
zhoupenghui1688 分钟前
golang时间相关函数总结
服务器·前端·golang·time
孤雪心殇10 分钟前
简单易懂,解析Go语言中的Map
开发语言·数据结构·后端·golang·go
White graces22 分钟前
正则表达式效验邮箱格式, 手机号格式, 密码长度
前端·spring boot·spring·正则表达式·java-ee·maven·intellij-idea
庸俗今天不摸鱼22 分钟前
Canvas进阶-4、边界检测(流光,鼠标拖尾)
开发语言·前端·javascript·计算机外设
菠菠萝宝23 分钟前
【Java八股文】10-数据结构与算法面试篇
java·开发语言·面试·红黑树·跳表·排序·lru
奔跑吧邓邓子26 分钟前
【Python爬虫(36)】深挖多进程爬虫性能优化:从通信到负载均衡
开发语言·爬虫·python·性能优化·负载均衡·多进程
不会Hello World的小苗30 分钟前
Java——链表(LinkedList)
java·开发语言·链表
lsx20240642 分钟前
Perl 面向对象编程指南
开发语言
bubusa~>_<1 小时前
解决npm install 出现error,比如:ERR_SSL_CIPHER_OPERATION_FAILED
前端·npm·node.js