35 lines
919 B
JavaScript
35 lines
919 B
JavaScript
export const usePojmiStore = defineStore('pojmi', {
|
|
state: () => ({
|
|
pojmi: {}
|
|
}),
|
|
actions: {
|
|
async naloziPojme(jezik) {
|
|
const { jsonApiUrl, headers, deserialize } = useApi()
|
|
|
|
const data = await $fetch(`${jsonApiUrl(jezik)}/node/concept?sort=-changed`, { headers })
|
|
this.pojmi = await deserialize(data, s => ({
|
|
id: s.id,
|
|
naslov: s.title,
|
|
tekst: s.body ? s.body.processed : '',
|
|
media: s.fieldMedia,
|
|
strojni_prevod: s.fieldStrojniPrevod
|
|
}), 'naslov')
|
|
},
|
|
|
|
async ustvariPojem(data) {
|
|
const { baseUrl, headers, deserialize } = useApi()
|
|
|
|
const req = await $fetch(`${baseUrl}/api/pojem/dodaj`, {
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json'
|
|
},
|
|
method: "POST",
|
|
body: JSON.stringify(data)
|
|
})
|
|
|
|
const resp = await req.json()
|
|
}
|
|
}
|
|
})
|