From 865d186d7367a1980538507c23d006bdbf260e2c Mon Sep 17 00:00:00 2001 From: yyeonzu Date: Sun, 26 Jan 2025 19:58:41 +0900 Subject: [PATCH] =?UTF-8?q?:recycle:=20postServer=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0=20(#274)=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=A0=9C=EB=84=88=EB=A6=AD=20=EC=82=AD=EC=A0=9C,?= =?UTF-8?q?=20apiResponse=20=ED=83=80=EC=9E=85=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/server.ts | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/apis/server.ts b/src/apis/server.ts index aaa894bb..0f116319 100644 --- a/src/apis/server.ts +++ b/src/apis/server.ts @@ -19,31 +19,25 @@ import { ApiErrorResponse } from '@src/types/apis/apiResponse'; const SERVER_BASE_URL = '/servers'; const buildServerUrl = (path: string = '') => `${SERVER_BASE_URL}${path}`; -export const postServer = async < - Res = { serverId: number }, - Req extends { - name: string; - description: string; - serverImg: File | null; - } = Pick & { - serverImg: File | null; - }, ->( - body: Req, +export const postServer = async ( + body: PostServerReq, headers?: Record, -): Promise => { +): Promise> => { const formData = new FormData(); formData.append('name', body.name); formData.append('description', body.description); if (body.serverImg) { formData.append('serverImg', body.serverImg); } - - const response = await authClient.post>( - buildServerUrl(), - formData, - { headers: { 'Content-Type': 'multipart/form-data', ...headers } }, - ); + const response = await authClient.post< + ApiResponse<{ serverId: number }>, + AxiosResponse> + >(buildServerUrl(), formData, { + headers: { + 'Content-Type': 'multipart/form-data', + ...headers, + }, + }); return response.data; };