adonisjs / inertia

Official Inertia.js adapter for AdonisJS
MIT License
74 stars 9 forks source link

Fix error when passing model with @computed() or pagination to Inertia.js #20

Closed lncitador closed 5 months ago

lncitador commented 5 months ago

šŸ”— Linked issue

Error passing model with @computed() or pagination to Inertia.js #19

ā“ Type of change

šŸ“š Description

Hello team,

I would like to report a problem I have encountered when dealing with models that contain @computed() or when passing pagination to Inertia.js in my project. When doing so, an error occurs within the @adonisjs/inertiajs package.

To resolve this issue in my project, I developed a serialization method before passing the data to Inertia.js. This approach allowed me to reprocess the data or send it to the browser without encountering the aforementioned error.

In addition, I took the opportunity to update a type I had created for a provider previously used with @pyxlab/adonis-trpc in Adonis. I modified the return from InferPageProps to return Infer instead of Serialize. This was done because the Serialize type only returned ModelObject when a model was passed in.

I'm happy to provide more details or help you solve this problem.