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
Do you know what is method spoofing in laravel?
How to enable or disable maintaince mode in laravel.
Is laravel built on symfony?
Difference between facades vs. Dependency injection?
How do I log an error?
Explain me active record implementation?
What is laravel route?
Explain laravel’s middleware?
Explain few features of laravel?
Explain me what is your favorite feature of laravel?
How to use laravel framework in php?
What is bearer token?
How to Storing Session Data in Laravel ?
In which directory laravel configartion files are kept.
What is database migration used in laravel 5? Explain