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 is lts version of laravel?
What is laravel mvc?
What are events in laravel?
How to use aggregate functions in laravel query?
How to use update statement in laravel?
Explain bundles in laravel?
Can you explain about serialization?
How to add a middleware in route group?
How to use delete statement in laravel?
Define laravel guard.
Explain elixir in laravel?
What are named routes in laravel?