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
Explain the controllers in laravel?
What are the official packages provided by laravel?
What is namespace in php laravel?
What is middleware in laravel?
Do you know laravel eloquent?
What is laravel quora?
Is it easy to learn laravel?
Explain the service container?
Tell me how can you display html with blade in laravel?
How can someone change the default database type in laravel?
How to make a constant and use globally?
Tell me what is database migration? And how to use it to add insert initial data to database?
How do I know laravel version?
Explain bundles in laravel?
What is url helper?