Answer the question
In order to leave comments, you need to log in
How to correctly accept json in laravel?
Tell me how to correctly accept Json in Laravel? I'm just starting to get to know this, I can't figure it out. Let's give json to me it's clear about how. A request came, we look in the database, if there is, we give it back. More or less like this.
$model= Model::find($id);
return response()->json($model, 200);
{
"test": 123,
"123": 43
}
$request->all()
Answer the question
In order to leave comments, you need to log in
On the lara side, you can do this:
https://laravel.com/docs/8.x/requests#retrieving-j...
But the request must have a header
Content-Type: application/json
Well, you can safely validate
https://laravel.com/docs/ 8.x/validation#validating...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question