Hey Manoj, 👋🏽
Prisma runs on the server-side. If you're using Nuxt, you can run Prisma in the asyncData and fetch hooks at either a page or component level.
asyncData
fetch
I created a small demo you can check out experimenting how this would work. Your feedback on this would be appreciated too 🙂
I managed to create a middleware API in Nuxt I also tried PrismaClient as Vue plugin(Vue.use) and it fails. Same result in Vuex store.
gist.github.com/manojap/fb0d973551...
Here is my sandbox codesandbox.io/s/nuxt-api-prisma-a...
The sample on Codesandbox should work just fine. I've managed to query data – both the REST and GraphQL API.
Could you share the error you get when you use a Vue plugin?
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey Manoj, 👋🏽
Prisma runs on the server-side. If you're using Nuxt, you can run Prisma in the
asyncData
andfetch
hooks at either a page or component level.I created a small demo you can check out experimenting how this would work. Your feedback on this would be appreciated too 🙂
I managed to create a middleware API in Nuxt
I also tried PrismaClient as Vue plugin(Vue.use) and it fails.
Same result in Vuex store.
gist.github.com/manojap/fb0d973551...
Here is my sandbox
codesandbox.io/s/nuxt-api-prisma-a...
The sample on Codesandbox should work just fine. I've managed to query data – both the REST and GraphQL API.
Could you share the error you get when you use a Vue plugin?