vue发送axios网络请求
------------恢复内容开始------------
【get】 带param参数和请求头
方式1
axios({
method: "get",
url: this.api + "/getstudent",
params: {
limit: 1,
size: 5,
},
})
.then((res) => {
// 登陆失败
console.log(res.data);
})
方式2
axios.get('http://192.168.0.111:8008/api/index/banner', {
params: {
ID: 12345
},
headers: {
'Authorization': 'nimabi',
"Cookie": 'cooikd'
}
})
.then(function (response) {
console.log(response.data.data);
})
.catch(function (error) {
console.log(error);
});
【post】 带参数和自定义请求头
axios({
method: 'post',
url: 'http://127.0.0.1/test',
data: {
id: 10,
name: '卢本伟',
type: 3,
description: '好书'
},
headers: {
'aaaaaa': 'bbbbb'
}
}).then(res => {
console.log(res.data.data)
}).catch(err => {
console.error(err);
});
请求头内容

请求参数:


浙公网安备 33010602011771号