return Response::json(array(
'status' => 200,
'posts' => $post->toArray()
), 200);
Using the code above, I returned the data in json format.
I saw other api that return json, returning it in a formatted form.
For example:
http://api.steampowered.com/ISteamNews/GetNewsForApp/v0002/?appid=440&count=3&maxlength=300&format=json
But mine returns it in one line. How to create json in a formatted way with laravel?
Update
I still can’t verify the code until tomorrow. Therefore, I agree with the answer.
But this is api
http://laravel.com/api/class-Illuminate.Support.Facades.Response.html
and parameters:
$data
$status
$headers
Update
In fact, I modified the backlight response class to have this constant.
source
share