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 |
Tell me how to enable the query logging?
What is factory in laravel?
What is query scope?
How to start and stop valet?
what is meant by Global Middleware and Route Middleware ?
How to share data with views?
How to know laravel version?
Is laravel faster than rails?
Please provide steps to configure homestead?
List the default ports that are forwarded to your homestead environment?
How to use update statement in laravel?
How to get current route name?