axios

axios中get请求与post请求的简单函数封装,axios全

2020-01-21  本文已影响0人  丁先生_b64b

axios中get请求与post请求的简单函数封装,axios全局请求参数设置,请求及返回拦截器

一、

https://www.kancloud.cn/yunye/axios/23484

https://www.cnblogs.com/kyl-6/p/9502779.html

二、

axios.interceptors 拦截器,拦截请求前和请求后,then,catch处理之前,对数据进行处理:

https://blog.csdn.net/panyox/article/details/73800241

今天讲的如何将axios的post请求与get请求封装在一起利用的是axios(config)

1、get请求

axios({    methods:'get',    url:'/user',    params: {        ID:'1234'}}).then((response)=>{console.log(response);}).catch((error)=>{console.log(error);});

2、post请求

axios({    methods:'post',    url:'/user',    data: {        ID:'1234'}}).then((response)=>{console.log(response);}).catch((error)=>{console.log(error);});

上一篇 下一篇

猜你喜欢

热点阅读