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 |
Can you exclude uris from csrf protection in laravel? Explain
What is the service container in laravel?
What is laravel horizon?
What is use of laravel?
What is the difference between laravel and symfony?
Is laravel spark free?
Do you know what is routing and how, and what are the different ways to write it?
Explain me how to assign multiple middleware to laravel route ?
How to create Controller Laravel - File Uploading ?
How to use basic routing in laravel?
What is csrf protection in laravel?
What is routing and how, and what are the different ways to write it?