Share code between backend and frontend (Inertia) #4989
Unanswered
rickyryden
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I did this in my
start/routes.ts
file:I then used
routes.auth.login
when defining routes (in the same file), but also importedroutes
in both controllers and my React components (using Inertia).The idea was to have all my routes defined in one place so that I don't have to write them manually everywhere. Examples:
But I ran into this problem: https://docs.adonisjs.com/guides/views-and-templates/inertia#top-level-await-is-not-available because I shared code between backend and frontend.
So, my question is, how can I do something similar without running into errors and problems? I would like to do something similar with other stuff later on (not just routes), so that I can use code from one place in both backend and frontend.
Beta Was this translation helpful? Give feedback.
All reactions