How can I access the $prismic API from a Pinia store?

The $prismic API is available in Vuex as described here (https://prismic.nuxtjs.org/fetching-content/#from-a-page). However, I'm having trouble accessing this from Pinia. Any tips on how to reach it?

Hey @bassplayer7, how are you making your page queries?
Can you show us an example?

I found out that Pinia includes $nuxt in it's context. So this works:

this.$nuxt.$prismic.api.getSingle(/*...*/)
1 Like

Thanks for sharing your solution @bassplayer7!

In Nuxt 3, it would be :
const nuxt = useNuxtApp(); nuxt.$prismic.client.getSingle()
I guess

1 Like