G
G
GrimJack2017-09-11 18:16:54
Laravel
GrimJack, 2017-09-11 18:16:54

Request not coming, why?

Made a post route. For tests, I removed it from csrf protection. I send data to it via postman (via the date form and tried it via raw-> json), in the controller

public function test(Request $request)
    {
        dd($request->all());
    }

In the output I get []
What could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
seriogja, 2017-09-11
@GrimJack

Good afternoon!
You are getting json data, not form inputs. Therefore, you receive through or through . You can also do this: When sending JSON requests to your application, you may access the JSON data via the input method as long as the Content-Type header of the request is properly set to application/json. You may even use "dot" syntax to dig into JSON arrays:json_decode($request->getContent(), true)$request->json()->all()
$name = $request->input('user.name');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question