Support the ongoing development of Laravel.io →
posted 10 years ago
Security
Last updated 2 years ago.
0
Solution

maybe put it within another array?

echo Response::json(array('data' => array(array('name' => 'Test'))));
Last updated 2 years ago.
0

Thanks! That works great.

Last updated 2 years ago.
0

Use this package awesome....

"league/fractal": "0.8.*"
Last updated 2 years ago.
0

You could always do something like this, in filters.php:

App::after(function($request, $response)
{
    if ($response instanceof Symfony\Component\HttpFoundation\JsonResponse)
        $response->setData(['result' => $response->getData()]);
});

Note that I used result here rather than data, if you prefer data then just change it

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.