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 assign a variable value for all view file?
What is an api route?
Is any server permissions required for laravel?
What is the default session timeout duration?
Tell me how to get current environment in laravel 5?
What is the use of db facade?
Explain the types of dependency injection?
What is contextual binding?
How to get Retrieving the Request URI ?
List the requirements to install valet?
How to configure route cache and clear route cache in laravel?
Is laravel a good framework?