mardi 2 avril 2019

How to fix "Trying to get property 'id' of non-object" in laravel?

I'm having a problem of getting the object property from the front-end passed by axios to PHP laravel resource controller.

axios({
   method:post,
   url: ...
   data: {
     obj: {id:1,name:'Foo',age:25}
   }
})

public function store(Request $request)
    {
        $res = $request->obj->id;
        return $res;
    }

I expect return value is 1, but in the console it says "Trying to get property 'id' of non-object".



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2UbJH8g
via IFTTT

Aucun commentaire:

Enregistrer un commentaire