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
Tell me what are pros and cons of using laravel framework?
How do I setup localization for an application?
What is eloquent orm in laravel?
How do I assign several roles to users and permit the users to perform some actions based on those roles?
Explain request life cycle of laravel.
What is a Terminable Middleware ?
Define implicit controller.
Is laravel support caching? Explain
Why should I use laravel?
Tell me is laravel an open source?
What is a Laravel - Authentication ?
what is Basic Routing ?
What is a check method ?
How to get last inserted id using laravel query?
How to start, stop mysql on valet?