//Vuejs2 //Laravel v7.x
I have hit a roadblock and cannot seem to find a solution. I am trying to retrieve data from my object in the controller. In my View.vue file, I am using axios to make a post request.
data() {
return {
customer: {
name: 'abc',
login: 'def'
},
file: null
}
},methods: {
submit(){
let formData = new FormData();
formData.append("customer", this.customer);
formData.append("file", this.file);
axios.post('/project/new',
formData, {
headers: {
"Content-Type": "multipart/form-data"
}
}).then(data => {
console.log(data.data);
});
}
}
In my controller, I am attempting to handle the data like this:
public function postProject(Request $request)
{
return $request->customer; //return [Object Object]
return $request->customer->name; //return Trying to get property 'name' of non-object
return $request->customer['name']; //return Illegal string offset 'name'
return $request->file; //return [Object Object]
}
Thank you for any assistance provided. Have a great day!