Posting JSON To Laravel

后端 未结 3 1631
温柔的废话
温柔的废话 2020-11-28 14:28

I am trying to make a post request of json to Laravel. The request is received on the server however when I try to access a property I get: \"Trying to get property

3条回答
  •  迷失自我
    2020-11-28 14:54

    To expand (and correct) the above, in Laravel 5 you would retrieve JSON as shown:

    public function handle_ajax(Request $request) {
        $data = (object) $request->json()->all();
        Clockwork::info($data->id);
    }
    

    In non-trivial examples you might want to also validate your input first.

提交回复
热议问题