[英]problem with axios get error 400 bad request
I have been stuck for quite a while because when I launch a call to my API to retrieve data (therefore a GET method) I have a 400 bad request error off on postman I manage to retrieve the data in status 200. However in my axios I pass the parameters well as well as the useful headers.我已经卡住了很长一段时间,因为当我调用我的 API 来检索数据(因此是 GET 方法)时,我在 postman 上关闭了 400 错误请求错误,我设法检索状态为 200 的数据。但是在我的 Z3DB28C3787D79339我传递参数以及有用的标题。
Code axios status 400:代码 axios 状态 400:
async getAssociatedPlant() { this.$axios.$get('lnk/plant/plants', { headers: { "Content-Type": "application/json", }, params: { link: "good", plant_id: this.plantActive.id, }, }).then(response => { console.log(response) }).catch(error => { console.log(error) }); },
Image useful for understanding:有助于理解的图像:
Postman Headers status 200 OK Postman 标题状态 200 OK
Postman Params status 200 OK Postman 参数状态 200 OK
Try adding data:{} to your request config.尝试将 data:{} 添加到您的请求配置中。
async getAssociatedPlant() {
this.$axios.$get('lnk/plant/plants', {
headers: {
"Content-Type": "application/json",
},
data:{},
params: {
link: "good",
plant_id: this.plantActive.id,
},
})
.then(response => {
console.log(response)
}).catch(error => {
console.log(error)
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.