Skip to content

Commit

Permalink
fix: remove axios status 200 check, axios automatically checks whethe…
Browse files Browse the repository at this point in the history
…r 2xx
  • Loading branch information
hwmin414 committed Mar 12, 2024
1 parent babdcaf commit 2d6bc84
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
20 changes: 9 additions & 11 deletions packages/web/src/components/ModalPopup/ModalMypageModify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,22 @@ const ButtonProfileImage = () => {
},
});
if (data.url) {
const res = await axiosOri({
await axiosOri({
url: data.url,
method: "put",
headers: {
"Content-Type": image.type,
},
data: image,
});
if (res.status === 200) {
const data2 = await axios({
url: "/users/editProfileImg/done",
method: "get",
});
if (data2?.result) {
fetchLoginInfo();
setProfileAlert("SUCCESS");
return;
}
const data2 = await axios({
url: "/users/editProfileImg/done",
method: "get",
});
if (data2?.result) {
fetchLoginInfo();
setProfileAlert("SUCCESS");
return;
}
}
setProfileAlert("FAIL");
Expand Down
4 changes: 1 addition & 3 deletions packages/web/src/hooks/chat/useSendMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ export default (
});
if (!url || !id) throw new Error();

const { status: s3Status } = await axiosOri({
await axiosOri({
url,
method: "put",
data: file,
headers: { "Content-Type": file.type },
});

if (s3Status !== 204) throw new Error();

const { result } = await axios({
url: "chats/uploadChatImg/done",
method: "post",
Expand Down
2 changes: 0 additions & 2 deletions packages/web/src/hooks/useTaxiAPI/useAxios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ const useAxios = () => {
`/login?redirect=${encodeURIComponent(currentPath)}`
)}`
);
} else if (res.status !== 200) {
throw new Error("Status is not 200!");
} else {
if (onSuccess) onSuccess(res.data);
return res.data;
Expand Down

0 comments on commit 2d6bc84

Please sign in to comment.