Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ [WV-42] refactor : api 수정 #58

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/news/apis.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// news-detail
const BASE_URL = process.env.NEXT_PUBLIC_API_KEY;
export const getNewsDetail = async (
artcSeq: string
): Promise<ArticleContentsResponse["data"]> => {
const queryparam = artcSeq ? `newsdetail?artcSeq=${artcSeq}` : "";

const url = `/api/article/${queryparam}`;
const url = `http://${BASE_URL}/api/article/${queryparam}`;
const res = await fetch(url);

if (!res.ok) {
Expand Down
9 changes: 5 additions & 4 deletions api/player/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import {
PitcherResponse,
} from "./types";

const BASE_URL = process.env.NEXT_PUBLIC_API_KEY;
// player - 코치 리스트
export const getCoachList = async (): Promise<CoachInfo[]> => {
const url = `/api/player/coachlist`;
const url = `http://${BASE_URL}/api/player/coachlist`;
const res = await fetch(url);

if (!res.ok) {
Expand All @@ -20,7 +21,7 @@ export const getCoachList = async (): Promise<CoachInfo[]> => {

// player - 투수 리스트
export const getPitcherList = async (): Promise<PitcherInfo[]> => {
const url = `/api/player/pitcherlist`;
const url = `http://${BASE_URL}/api/player/pitcherlist`;
const res = await fetch(url, { method: "GET" });
if (!res.ok) {
throw new Error("Failed to fetch coach list");
Expand All @@ -35,7 +36,7 @@ export const getCoachDetail = async (
pcode: string
): Promise<CoachDetailResponse["data"]> => {
const queryparam = pcode ? `coachdetail?pcode=${pcode}` : "";
const url = `/api/player/${queryparam}`;
const url = `http://${BASE_URL}/api/player/${queryparam}`;
const response = await fetch(url, { method: "GET" });

if (!response.ok) {
Expand All @@ -51,7 +52,7 @@ export const getPitcherDetail = async (
pcode: string
): Promise<PitcherDetailResponse["data"]> => {
const queryparam = pcode ? `pitcherdetail?pcode=${pcode}` : "";
const url = `/api/player/${queryparam}`;
const url = `http://${BASE_URL}/api/player/${queryparam}`;
const response = await fetch(url, { method: "GET" });

if (!response.ok) {
Expand Down
Loading