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

相关推荐
CoderYanger1 分钟前
优选算法-字符串:63.二进制求和
java·开发语言·算法·leetcode·职场和发展·1024程序员节
3***31212 分钟前
java进阶1——JVM
java·开发语言·jvm
charlie1145141918 分钟前
深入理解C/C++的编译链接技术6——A2:动态库设计基础之ABI设计接口
c语言·开发语言·c++·学习·动态库·函数
IT_陈寒10 分钟前
Python高手都在用的5个隐藏技巧,让你的代码效率提升50%
前端·人工智能·后端
Cx330❀11 分钟前
C++ STL set 完全指南:从基础用法到实战技巧
开发语言·数据结构·c++·算法·leetcode·面试
white-persist14 分钟前
【攻防世界】reverse | Reversing-x64Elf-100 详细题解 WP
c语言·开发语言·网络·python·学习·安全·php
FeiHuo5651514 分钟前
微信个人号开发中如何高效实现API二次开发
java·开发语言·python·微信
zmzb010316 分钟前
C++课后习题训练记录Day33
开发语言·c++
csbysj202018 分钟前
Bootstrap 折叠
开发语言
lcc18724 分钟前
Vue3 ref函数和reactive函数
前端·vue.js