basic pinia store

This commit is contained in:
vabene1111
2023-02-12 16:06:00 +01:00
parent cb363d6321
commit 3af7e98216
6 changed files with 134 additions and 17 deletions

View File

@@ -0,0 +1,33 @@
https://pinia.vuejs.org/core-concepts/plugins.html#adding-new-state
export function BaseStorePlugin () {
return {
collection: [],
item: {},
getCollection: function (url) {
api.get(url)
.then((response) => {
this.collection = response.data;
})
.catch((error) => {
this.handleError(error);
});
},
getItem: function (url) {
api.get(url)
.then((response) => {
this.item = response.data;
})
.catch((error) => {
this.handleError(error);
});
},
handleError: function (error) {
window.alert(error);
},
};
}