manifest/nuxt/stores/strani.js

18 lines
427 B
JavaScript

export const useStraniStore = defineStore('strani', {
state: () => ({
strani: {}
}),
actions: {
async naloziStrani () {
const { jsonApiUrl, headers, deserialize } = useApi()
const data = await $fetch(`${jsonApiUrl}/node/page`, { headers })
this.strani = await deserialize(data, s => ({
id: s.id,
naslov: s.title,
tekst: s.body.processed
}), 'naslov')
}
}
})