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 |
How to upgrade valet to valet 2.0?
Explain how to create custom middleware in laravel?
Who are Manually Authenticating Users in Laravel ?
What is map function in laravel?
What is the use of php compact function?
Explain the controllers in laravel?
Explain how to create a controller in laravel?
How to localize resource uris in laravel?
Is laravel backend?
How to turn off crsf protection for specific route in laravel?
Do you know what is php artisan.
How will you register service providers?