Just to add on this answer: https://stackoverflow.com/a/73597297/18322745 by @LuckyLooke
You can put the getADPs() function outside the store (e.g. in a separate file called 'ADPService.ts') and the you can fetch them in the store during state initialization as shown below:
import getADPs from '@/services/ADPService.ts';
export const listadoADPs = defineStore("listado", {
state: () => ({
adps: getADPs(),
}),
getters: {
...
},
});
Then the getADP function can be like:
export default function getADPs() {
const api = "your API URL";
return fetch(api)
.then((response) => response.json())
.then(({ data }) => (return data))
.catch((error) => console.log(error));
}