Fork me on github

Axios之get post请求

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

axios的作用:向后台发起请求的,可以发出含参请求,有get和post方式。
npm安装
:npm install axios
也可以使用淘宝镜像进行安装
:cnpm install axios

axios get请求

 axios.get(url)//如果需要传入参数,可以使用?来传参。

.then(function (response) {

console.log(response);})

.catch(function (error) {

console.log(error);});
       // 也可以使用这种方式进行传入参数
axios.get(url, {
params: {
  ID: 00000
}})

axios post请求

axios.post('url', {
UserName: 'xxxx',
PassWord: 'xxxx'})
.then(function (response) {
console.log(response);})
.catch(function (error) { //请求error
console.log(error);});
posted on 2020-05-07 16:58  markyle  阅读(662)  评论(0编辑  收藏  举报