Skip to content

Commit

Permalink
refactor: (#153) delete를 패치하는 함수 오류 제거를 위한 리팩터링
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilpop8663 committed Jul 31, 2023
1 parent e69419c commit cbfa698
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions frontend/src/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,20 @@ export const putFetch = async <T, R>(url: string, body: T): Promise<R | void> =>
return data;
};

export const patchFetch = async (url: string) => {
export const patchFetch = async <T>(url: string, body: T) => {
const response = await fetch(url, {
method: 'PATCH',
headers,
body: JSON.stringify(body),
});

const data = await response.json();

if (!response.ok) {
throw new Error(data.message);
}

return response;
};

export const deleteFetch = async (url: string) => {
Expand All @@ -74,11 +77,7 @@ export const deleteFetch = async (url: string) => {
headers,
});

const data = await response.json();

if (!response.ok) {
throw new Error(data.message);
}
return response;
};

export const multiPostFetch = async (url: string, body: FormData) => {
Expand Down

0 comments on commit cbfa698

Please sign in to comment.