【知识整理】Axios-如何发送一个GET请求

来源:互联网 发布:js遍历jsonarray对象 编辑:程序博客网 时间:2024/06/15 22:34

一.发送一个GET请求

1.将请求参数挂载到请求的url中的形式:

axios.get('/user?id=123&lpage=1').then(function(response){console.log(response);//请求正确时执行的代码}).catch(function (response){console.log(response);//发生错误时执行的代码});
2.将请求参数单独的params属性传入的形式:
axios.get('/user', {params : { //请求参数id : 123}}).then(function(response){console.log(response);//请求正确时执行的代码}).catch(function(response){console.log(response);//发生错误时执行的代码})


原创粉丝点击