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 auth?
What is url helper?
What is redirect routes?
How to use where null and where not null eloquent query in laravel?
What do you maen by method spoofing in laravel 5?
What are the benefits of laravel?
What is use in laravel?
How to install laravel?
What is a service provider laravel?
What is meant by Laravel - Validation ?
Can you update homestead? If yes, how?
What is contextual binding?