1
0
forked from noxious/client
2024-08-20 02:16:18 +02:00

27 lines
639 B
TypeScript

import { defineStore } from 'pinia'
import { type Asset } from '@/types'
import config from '@/config'
export const useAssetStore = defineStore('assets', {
state: () => ({
assets: [] as Asset[]
}),
actions: {
setAssets(assets: Asset[]) {
this.assets = assets
},
async fetchAssets() {
return fetch(config.server_endpoint + '/assets')
.then((response) => response.json())
.then((assets) => {
this.setAssets(assets)
return true
})
.catch((error) => {
console.error('Error fetching assets:', error)
return false
})
}
}
})