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.
Code axios status 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 :
Try adding data:{} to your request config.
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)
});
}