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
Explain me how to assign multiple middleware to laravel route ?
Explain the difference between laravel and codeigniter?
How do I see all of the routes that are defined?
What is the purpose of using dd() function iin laravel?
How to assign a variable value for all view file?
Is laravel easier than php?
What are the applications supported by valet?
What are the differences between laravel and codeigniter?
Define http middleware?
What is difference between single quote and double quote?
What is composer in laravel?
What is composer lock in laravel?
What is escape string?
Explain how to install installing mariadb on homestead?
How can you update homestead?