The Sheriff
The Sheriff
NNuxt
Created by The Sheriff on 5/9/2024 in #❓・help
How do I get access to nuxtApp plugins inside Composition API store?
import { defineStore } from 'pinia';

export const usemyStore = defineStore('myStore', () => {
const { $api, $rollbar, } = useNuxtApp();
console.log($rollbar);

const stuff = ref(null);

async function fetchStuff() {
try {
const response = await $api('/stuff', {
method: 'GET',
});
stuff.value = response?.providers || null;
} catch (err) {
$rollbar.error('fetchStuff failed:::', err);
console.log('fetchStuff failed:::', err);
}
}

return {
fetchStuff,
};
});
import { defineStore } from 'pinia';

export const usemyStore = defineStore('myStore', () => {
const { $api, $rollbar, } = useNuxtApp();
console.log($rollbar);

const stuff = ref(null);

async function fetchStuff() {
try {
const response = await $api('/stuff', {
method: 'GET',
});
stuff.value = response?.providers || null;
} catch (err) {
$rollbar.error('fetchStuff failed:::', err);
console.log('fetchStuff failed:::', err);
}
}

return {
fetchStuff,
};
});
1 replies
NNuxt
Created by The Sheriff on 5/1/2024 in #❓・help
How do I get nuxtApp.hook('app:created', (the app setup / store initialisations) to run before the m
How do I get nuxtApp.hook('app:created', (the app setup / store initialisations) to run before the middleware? Need some help here guys - very frustrating situation:
"nuxt": "^3.7.4",
"@pinia/nuxt": "^0.4.1",
"nuxt": "^3.7.4",
"@pinia/nuxt": "^0.4.1",
3 replies