Answer Posted / 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 |
Post New Answer View All Answers
How can we handle Error Handling in Laravel ?
How do I perform dependency injection in laravel?
Explain homestead in laravel.
Tell me does laravel support caching?
How will you check table is exists or in the database?
What is laravel homestead?
How can you generate urls?
How to create model controller and migration in a single artisan command in laravel?
What is url helper?
What does double quotation mean?
How does antiforgerytoken work?
What is xss attack with example?
What route model binding?
How to get data between two dates with query in laravel?
How do you install laravel?