feat: Scaffold new Nuxt.js application with initial pages, layouts, composables, and middleware.
This commit is contained in:
parent
ab3124628c
commit
9bfb852ad0
8 changed files with 113 additions and 48 deletions
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
// Interface สำหรับข้อมูลหมวดหมู่ (Category)
|
||||
export interface Category {
|
||||
id: number
|
||||
name: {
|
||||
|
|
@ -24,17 +24,20 @@ export interface CategoryData {
|
|||
categories: Category[]
|
||||
}
|
||||
|
||||
export interface CategoryResponse {
|
||||
interface CategoryResponse {
|
||||
code: number
|
||||
message: string
|
||||
data: CategoryData
|
||||
}
|
||||
|
||||
// Composable สำหรับจัดการข้อมูลหมวดหมู่
|
||||
export const useCategory = () => {
|
||||
const config = useRuntimeConfig()
|
||||
const API_BASE_URL = config.public.apiBase as string
|
||||
const { token } = useAuth()
|
||||
|
||||
// ฟังก์ชันดึงข้อมูลหมวดหมู่ทั้งหมด
|
||||
// Endpoint: GET /categories
|
||||
const fetchCategories = async () => {
|
||||
try {
|
||||
const response = await $fetch<CategoryResponse>(`${API_BASE_URL}/categories`, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue