-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
250 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// closetApi.js | ||
|
||
export const deleteCloth = async (clothId) => { | ||
try { | ||
const response = await fetch( | ||
`http://localhost:3000/FITple/my/closet/${clothId}/modify`, | ||
{ | ||
method: "DELETE", | ||
credentials: "include", // 세션 쿠키 포함 | ||
} | ||
); | ||
|
||
if (!response.ok) { | ||
throw new Error("Failed to delete the cloth"); | ||
} | ||
|
||
return response.json(); // 성공 시 응답 데이터를 반환 | ||
} catch (error) { | ||
console.error("Error deleting cloth:", error); | ||
throw error; // 에러 발생 시 호출하는 곳에서 처리하도록 던짐 | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const updateCloth = async (clothId, updatedData) => { | ||
try { | ||
const response = await fetch( | ||
`http://localhost:3000/FITple/my/closet/${clothId}/modify`, | ||
{ | ||
method: "PUT", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
credentials: "include", // 쿠키 등의 인증 정보 포함 | ||
body: JSON.stringify(updatedData), // 수정할 데이터 | ||
} | ||
); | ||
|
||
if (!response.ok) { | ||
throw new Error("Failed to update the cloth information"); | ||
} | ||
|
||
const data = await response.json(); | ||
return data; | ||
} catch (error) { | ||
console.error("Error updating cloth information:", error); | ||
throw error; // 필요에 따라 에러 처리 | ||
} | ||
}; | ||
export default updateCloth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.