Answer Posted / surbhi
JSON response can be sent using the json method.
This method will automatically set the Content-Type header to application/json.
The json method will automatically convert the array into appropriate json response.
Example :
Route::get('json',function(){
return response()->json(['name' => 'Gandhi', 'state' => 'Gujarat']);
});
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is bearer token?
How do you generate urls?
How to Create Creating a Cookie in Laravel ?
Please explain laravel query builder?
What is php artisan in laravel?
How to get Retrieving the Request URI ?
What route model binding?
Explain laravel service container?
what is meant by CSRF Protection in Laravel ?
How to start and stop valet?
What is meant by Implicit Controllers
Do you know laravel eloquent?
How to access laravel project from another computer?
How to configure route cache and clear route cache in laravel?
Do you know what is laravel elixir?