Tech
Inertia and API responses living together in harmony
I love InertiaJS to the point where it's becoming a personality trait
I tend to want to use it for everything, but adding Inertia to an existing Laravel API gets awkward fast. Same thing happens in the other direction: you start with a full Inertia frontend and then realize you want to expose some of that data as a public API too.
The naive solutions are:
Sprinkle if ($request->wantsJson()) into your controllers
Maintain two separate routes that return the exact same data
...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to