axios、Fetch

发布时间 2023-03-22 21:09:23作者: 想见玺1面

axios

 1、axios是什么

axios是一个基于Promise的HTTP库,可以用在浏览器和node.js中

第三方Ajax库

http://www.axios-js.com/zh-cn/docs/

2、axios的基本用法

引入axios

console.log(axios);

 请求时的头信息

headers:{

  ' Content-Type ':' application/x-www-form-urlencoded '

},

 通过请求头携带的数据

params:{

  username:' alex '

},

通过请求体携带的数据

 

 

 Fetch

1、Fetch是什么

Fetch也是前后端通信的一种方式

Fetch是Ajax(XMLHttpRequest)的一种代替方案,它是基于Promise的

Ajax的兼容性比Fatch好

2、Fetch的基本用法