24/7/12总结

axios

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

get请求:

 <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请求: 

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);
  });

多并发:

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. P2471 [SCOI2007] 降雨量

    2024-07-13 09:22:04       29 阅读
  2. hive总结

    2024-07-13 09:22:04       58 阅读
  3. CSS总结

    2024-07-13 09:22:04       57 阅读
  4. HTML总结

    2024-07-13 09:22:04       54 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-13 09:22:04       70 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-13 09:22:04       74 阅读
  3. 在Django里面运行非项目文件

    2024-07-13 09:22:04       62 阅读
  4. Python语言-面向对象

    2024-07-13 09:22:04       72 阅读

热门阅读

  1. STL内建仿函数

    2024-07-13 09:22:04       24 阅读
  2. 开源 Wiki 系统 InfoSphere 2024.01.1 发布

    2024-07-13 09:22:04       30 阅读
  3. macOS 的电源适配器设置

    2024-07-13 09:22:04       29 阅读
  4. PTA 7-14 畅通工程之局部最小花费问题

    2024-07-13 09:22:04       28 阅读
  5. Vue单路由的独享守卫怎么设置

    2024-07-13 09:22:04       28 阅读
  6. 代码随想录算法训练营第33天

    2024-07-13 09:22:04       26 阅读
  7. 总结:Hadoop高可用

    2024-07-13 09:22:04       29 阅读
  8. 使用Python进行音频处理:掌握音频世界的魔法

    2024-07-13 09:22:04       28 阅读
  9. ssh:(xshell)远程连接失败

    2024-07-13 09:22:04       25 阅读
  10. Hadoop 面试题(十一)

    2024-07-13 09:22:04       27 阅读
  11. 深入理解外观模式(Facade Pattern)及其实际应用

    2024-07-13 09:22:04       24 阅读