Skip to content

Commit 14ef140

Browse files
authored
Merge pull request #1568 from mfts/fix/avatar-upload
fix: return on 200 not just 201
2 parents e42164c + 275fa39 commit 14ef140

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

components/account/upload-avatar.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ const UploadAvatar = ({
5959
body: JSON.stringify({ image: blobUrl }),
6060
}).then(async (res) => {
6161
setUploading(false);
62-
if (res.status === 201) {
63-
await update();
64-
toast.success("Successfully updated your profile picture!");
65-
} else {
62+
if (!res.ok) {
6663
const errorMessage = await res.text();
6764
toast.error(errorMessage || "Something went wrong");
65+
return;
6866
}
67+
await update();
68+
toast.success("Successfully updated your profile picture!");
6969
});
7070
}}
7171
className="rounded-lg"

pages/api/account/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default async function handle(
9999
},
100100
});
101101

102-
return res.status(200).json(response);
102+
return res.status(200).json({ message: "success" });
103103
} catch (error) {
104104
errorhandler(error, res);
105105
}

0 commit comments

Comments
 (0)