mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-02 04:39:54 -05:00
33 lines
819 B
JavaScript
33 lines
819 B
JavaScript
|
|
|
|
|
|
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);
|
|
},
|
|
};
|
|
} |