How to get JSON Response on Laravel ?
Answer / 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 |
What do you know about laravel contracts?
What do you mean by make() method?
How to use session in laravel?
Explain how can you write your own service provider in laravel?
Explain what are laravel facades?
How to create model controller and migration in a single artisan command in laravel?
How to write html code in laravel controller?
What is design pattern in laravel?
Explain contextual binding and how does it work?
What is the use of blade?
Tell me how to get current environment in laravel 5?
What are class traits?