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,
};
});
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server