axios的GET和POST说明

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/longlc123/article/details/82497708

axios 地址:https://github.com/axios/axios

GET请求参数挂在到请求的url中的形式

axios.get('/user?id=123&lpage=1').then(function(response){
    console.log(response);//请求正确时执行的代码
}).catch(function (response){
    console.log(response);//发生错误时执行的代码
});

GET请求参数单独通过params传入其中

axios.get('/user', {
    params : { //请求参数
        id : 123
    }
}).then(function(response){
    console.log(response);//请求正确时执行的代码
}).catch(function(response){
    console.log(response);//发生错误时执行的代码
})

POST请求参数传到后台的方式

axios.post('/user', {
    firstName: 'Fred',
    lastName: 'Flintstone'
})
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error);
});
1.8.0(正式版本)   1.8.0.rc(灰度版本)  1.8.0.bate(测试版本) github的release说明。

问题
http和https区别 http1.0 和 http1.1 和 http2.0的区别

猜你喜欢

转载自blog.csdn.net/longlc123/article/details/82497708