Can you use a pinia store from a Nuxt 3 server route? (defineEventHandler) #2466
-
Is it possible to get the pinia instance from within defineEventHandler so that I can access my store from an api route?
Many thanks if anyone is able to answer this. |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Oct 29, 2023
Replies: 1 comment 1 reply
-
You can't but you also shouldn't need it. Server Routes are for API requests, they happen without the Nuxt (and vue) application running, so there isn't pinia, vue-router or anything like that. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jonesisg1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can't but you also shouldn't need it. Server Routes are for API requests, they happen without the Nuxt (and vue) application running, so there isn't pinia, vue-router or anything like that.
Instead, call the API from the store if you want and update the values in your store as a result of the API call