0
0
Fork 0
salix-front-mindshore-fork2/src/stores/useValidationsStore.js

27 lines
777 B
JavaScript
Raw Normal View History

2023-09-18 12:35:21 +00:00
import axios from 'axios';
import { defineStore } from 'pinia';
export const useValidationsStore = async () => {
const validationsStore = defineStore('validationsStore', {
state: () => ({
validations: null,
}),
actions: {
async fetchModels() {
if (this.validations) return;
try {
const { data } = await axios.get('Schemas/modelinfo');
this.validations = data;
} catch (error) {
console.error('Error al obtener las validaciones:', error);
}
},
2023-09-18 12:35:21 +00:00
},
});
const v = validationsStore();
if (!v.validations) {
await v.fetchModels();
}
return v.validations;
};