LT
LT
NNuxt
Created by LT on 11/25/2024 in #❓・help
About using callOnce
Hey all, Before the existence of the callOnce util, one of the recommended/suggested methods for initialising a store with data was to just simply call the action on app.vue (or layout.vue) which, according to my understanding, would load the data when loading the site for the first time, and then only call it again if we "hard refresh" the page. Now, can somebody clarify what is the difference between calling a store action directly inside app.vue's setup versus using the callOnce util? So basically, what is the functional difference between: app.vue (or layout.vue)
<script lang="ts" setup>
await store.getData()
</script>
<script lang="ts" setup>
await store.getData()
</script>
and app.vue (or layout.vue)
<script lang="ts" setup>
await callOnce(async () => {
await store.getData()
})
</script>
<script lang="ts" setup>
await callOnce(async () => {
await store.getData()
})
</script>
Cheers, thanks 👍
10 replies
NNuxt
Created by LT on 6/3/2024 in #❓・help
Accessing PM2 environment variables inside nuxt.config.ts ?
Hi all, I have a PM2 ecosystem file that's defining an APP_ENV=production/staging/development variable. But when I try to use process.env.APP_ENV==='production' inside nuxt.config.ts the result seems to always be false, even though running "pm2 env N" shows the enviromnent variable is set. Any suggestions or something obvious I'm missing?
2 replies