minhnt-dev: article api
This commit is contained in:
@@ -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));
|
||||
Reference in New Issue
Block a user