manifest/nuxt/stores/strani.js

18 lines
453 B
JavaScript

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