api 설정 분리

This commit is contained in:
2025-08-27 13:06:13 +09:00
parent ab84ef0d0e
commit ea3ec7de3b
5 changed files with 19 additions and 12 deletions

View File

@@ -16,13 +16,6 @@ export const useUserStore = defineStore("user", () => {
role: string
lastLoginAt: string
}
interface LoginResponse {
code: number
message: string
description: string
data: LoginData
}
// 게터
const isAdmin = computed(() => user.value?.role === "admin");
@@ -32,14 +25,14 @@ export const useUserStore = defineStore("user", () => {
try {
// 실제 API 호출로 대체할 수 있습니다
const {data, error: _error } = await useApi<LoginResponse>('/service/login', {
const {data, error: _error } = await useApi<ApiResponse<LoginData>>('/login', {
method: 'post',
body: { userId, password }
})
let mockUser;
if(data && data.value && data.value.code === 200){
if(data && data.value && data.value.success){
mockUser = data.value.data;
}else{
throw new Error("아이디 또는 비밀번호가 올바르지 않습니다.");