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 are laravel eloquent?
Explain the directory structure of laravel 5.6.
What is routing in laravel?
What is an api route?
Define implicit controller.
How can you display html with blade in laravel?
How do I add a 3rd party package to your application like laravel-emoji?
Laravle supports which databases?
What is laravel 5?
Tell me how to enable the query logging?
How install react js in laravel?
Explain the controllers in laravel?