So I'm attempting to send my post data to my controller and then access it via a object. It definitely passes the data but for some reason wont let me access any of the items with in that object its really weird.
Here is my post request in the vue component.
axios.post('/users', {user: this.user})
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error.response)
});
Here is what I have in my controller and as I said I do get the user info but I cant access it such as doing $user->id, but when I just do $user I can see the user data including the id.
//Here we get all the users info from the Axios Vue.
$user = $request->get('user');
return response()->json([
'status' => 'success',
'msg' => $user->id,
], 201);
The error I get is a php error as I can is it under the network response area and this is what the error message says.
"message": "Trying to get property 'id' of non-object"
But when I just do this in the controller.
//Here we get all the users info from the Axios Vue.
$user = $request->get('user');
return response()->json([
'status' => 'success',
'msg' => $user,
], 201);
It returns a 201 and shows this in the msg.
{"id":1,"email":"[email protected]","full_name":"John Doe","first_name":"John","last_name":"Doe","is_active":1,"overide_login":1,"skill_id":5,"phone":null,"shifts_id":0,"bilingual":0,"full_time":0}
Am I formatting the Object wrong or something?... It would be great if someone could help because I really don't understand why this does not work.
ALSO NOTE EVERYTHING IS ON THE NEWEST RELEASES OF VUEJS/AXIOS AND LARAVEL.