v0.1.22 - 로그인 오류 문구와 비로그인 화면 정리
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const AUTH_STORAGE_KEY = 'ten-minute-planner-auth'
|
||||
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:3001'
|
||||
import { buildApiUrl, toUserFacingApiError } from './apiBase'
|
||||
|
||||
function buildHeaders(token, extraHeaders = {}) {
|
||||
return {
|
||||
@@ -10,7 +10,7 @@ function buildHeaders(token, extraHeaders = {}) {
|
||||
}
|
||||
|
||||
async function request(path, { method = 'GET', token, body } = {}) {
|
||||
const response = await fetch(`${API_BASE_URL}${path}`, {
|
||||
const response = await fetch(buildApiUrl(path), {
|
||||
method,
|
||||
headers: buildHeaders(token),
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
@@ -19,7 +19,7 @@ async function request(path, { method = 'GET', token, body } = {}) {
|
||||
const data = await response.json().catch(() => ({}))
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.message || '요청 처리 중 문제가 발생했습니다.')
|
||||
throw new Error(toUserFacingApiError(data, '요청 처리 중 문제가 발생했습니다.'))
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
Reference in New Issue
Block a user