How to use API resources in Laravel Inertia?

Viewed 10

I am using Laravel 9, Jetstream, Inertia, Vue 3.

I have created an Api Resource for my Model Project

$projects = ProjectResource::collection(Project::get());

return Inertia::render('Project/Edit', compact('projects'));

In Vue, in the props "project" i get a nested array "data" and only the objects I need are already in it.

projects: Reactive
data:Array[2]
0:Object
1:Object

And it should be like this

projects:Reactive
0:Object
1:Object

I don't want to access props in vue via "projects.data" I want it to be: "projects" How to achieve this?

0 Answers
Related