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 difference between var_dump and print_r?
What is homestead in laravel?
How to install laravel via composer?
What is pluck method in laravel?
What is mvc framework?
Explain how to do 301 redirects in laravel?
Tell us how to use update statement in laravel?
What do you know about facades in laravel? Explain.
Tell me how to enable maintenance mode in laravel 5?
How to generate a controller with resources in laravel?
How to configure route cache in laravel?
Tell us what are bundles, reverse routing and the ioc container?