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 do I install laravel, talk about the different ways?
What is bearer token?
What is database migration used in laravel 5? Explain
How can we handle Error Handling in Laravel ?
How to generate a controller with resources in laravel?
List some official packages provided by laravel?
Explain the directory structure of laravel 5.6.
How to get Retrieving a Cookie in Laravel ?
What are the Severity Levels in Laravel ?
What is a Restful Resource Controllers ?
Explain some features of laravel?
What are Uses While Using the properties of Request instance ?