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
List types of the relationships supported by laravel?
How to get Retrieving the Request URI ?
Explain how to list all routes in laravel?
What is laravel 5 homestead?
What is contract in laravel?
How to start mysql on valet?
Define @include.
Explain loggin in laravel.
How to do dependency injection in laravel controllers?
What are the Versions Laravel - Understanding Release Process ?
Explain facades in laravel?
List out some artisan commands?
What are traits in laravel?
Which class is used to handle exceptions?
List the steps to configure laravel application.