diff --git a/src/api/alertApi.ts b/src/api/alertApi.ts index 4e7bd949..03fadddc 100644 --- a/src/api/alertApi.ts +++ b/src/api/alertApi.ts @@ -71,7 +71,7 @@ export interface AlertReadResponse { links: LinkInfo[]; } -/* 아래에 alert 관련 api 함수들 작성 */ +// GET /users/{user_id}/alerts - 유저의 알림 목록 조회 export const getAlerts = async (userId: string): Promise => { try { const response = await api.get( @@ -88,3 +88,24 @@ export const getAlerts = async (userId: string): Promise => { } } }; + +// PUT /users/{user_id}/alerts/{alert_id} - 알림 읽음 처리 +export const putAlerts = async ( + userId: string, + alertId: string, +): Promise => { + try { + const response = await api.put( + `/users/${userId}/alerts/${alertId}`, + ); + return response.data; + } catch (error) { + const axiosError = error as AxiosError; // 에러 타입 명시 + + if (axiosError.response) { + throw new Error(axiosError.response.data.message); + } else { + throw new Error('서버에 연결할 수 없습니다. 인터넷 연결을 확인해주세요.'); + } + } +};