DEV Community

Cover image for Laravel 9 - API Resources: With or Without "data"?
Sandro Jhuliano Cagara
Sandro Jhuliano Cagara

Posted on

3 2

Laravel 9 - API Resources: With or Without "data"?

If you use Eloquent API Resources to return data, they will be automatically wrapped in 'data'.

If you want to remove it, add JsonResource::withoutWrapping(); in app/Providers/AppServiceProvider.php.

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        JsonResource::withoutWrapping();
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
emerie55 profile image
Innocent Chiemerie Feargod

Still in Laravel 8

Collapse
 
sandrocagara profile image
Sandro Jhuliano Cagara • Edited

YES

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more