//8880 import { DEV_URL_FO, DEV_URL_WR } from "../config"; export const fetchType = { COMMON: "common", WR: "wr" }; interface RequestParams { [key: string]: unknown; } export const getFetch = async (type: string, url: string) => { const baseUrl = type === fetchType.COMMON ? DEV_URL_FO : DEV_URL_WR; const response = await fetch(baseUrl + url, { method: "GET", headers: { accept: "application/json", }, }); if (!response.ok) { throw new Error(`오류 발생: ${response.status}`); } const res = await response.json(); return res; }; export const postFetch = async (url: string, params: RequestParams) => { const response = await fetch(DEV_URL_WR + url, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(params), }); if (!response.ok) { throw new Error(`오류 발생: ${response.status}`); } return response; }; export const putFetch = async (url: string, params: RequestParams) => { const response = await fetch(DEV_URL_WR + url, { method: "PUT", headers: { "Content-Type": "application/json", }, body: JSON.stringify(params), }); if (!response.ok) { throw new Error(`오류 발생: ${response.status}`); } return response; }; export const deleteFetch = async (url: string, params: RequestParams) => { const response = await fetch(DEV_URL_WR + url, { method: "DELETE", headers: { "Content-Type": "application/json", }, body: JSON.stringify(params), }); if (!response.ok) { throw new Error(`오류 발생: ${response.status}`); } return response; };