minhnt-dev: article api

This commit is contained in:
MoreStrive
2024-05-31 00:46:43 +07:00
parent a7d4781a81
commit 7a92ca829f
11 changed files with 229 additions and 60 deletions
+18
View File
@@ -0,0 +1,18 @@
export const useArticleStore = defineStore("article", () => {
const currentArticle = ref<any>({});
const getArticleById = async (id: string | number) => {
try {
const { data } = await useFetch(`/api/articles/get-by-id/${id}`)
currentArticle.value = {}
currentArticle.value = data.value
} catch (error: any) {}
}
return {
currentArticle,
getArticleById
}
});
import.meta.hot && import.meta.hot.accept(acceptHMRUpdate(useArticleStore, import.meta.hot));