23 lines
620 B
TypeScript
23 lines
620 B
TypeScript
import { defineStore } from 'pinia'
|
|
import { SERVER_URL } from '../constants'
|
|
|
|
export const useFloorplanStore = defineStore('floorplan', {
|
|
state: () => {
|
|
return {
|
|
title: undefined,
|
|
np_array: [] as number[][]
|
|
}
|
|
},
|
|
actions: {
|
|
async getData() {
|
|
try {
|
|
const res = await fetch(`${SERVER_URL}/api/floorplan`)
|
|
const data = await res.json()
|
|
this.title = data.title
|
|
this.np_array = data.np_field
|
|
} catch (error) {
|
|
// this.list = []
|
|
}
|
|
},
|
|
}
|
|
}) |