This will help you.
Jul 11, 2022
5
Level 1
Laravel is not reading axios patch method parameters
I'm trying to upload form with products info the issue that is the backend is not reading the payload
let formData = new FormData();
formData.append('id',this.$refs.id.value);
formData.append('name',this.$refs.name.value);
formData.append('price',this.$refs.price.value);
axios.patch(this.updateUri,this.getFormData(),{
headers: {
"Content-Type": "multipart/form-data",
}
})
the update method in Products Controller:
public function update(){
return response()->json([
'code' => 200,
'request' => request()->all(),
]);
}
the response is {code: 200, request: []} & the payload :
id: 1
name: Qui vitae aut repellat aliquid quasi magnam.
price: 6.8435
Please or to participate in this conversation.