Skip to content

Commit 3e0ade9

Browse files
committed
fix: 프로필 수정 버그픽스
1 parent e87fafa commit 3e0ade9

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/components/Profile/UserCard.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ function cleanUrl(url) {
191191
return typeof url === 'string' ? url.split('?')[0] : ''
192192
}
193193
194+
function sanitizePayload(payload) {
195+
const cleanPayload = {}
196+
Object.keys(payload).forEach((key) => {
197+
cleanPayload[key] = payload[key] === '' ? null : payload[key]
198+
})
199+
return cleanPayload
200+
}
201+
194202
async function saveProfile() {
195203
try {
196204
let imageUrl = ''
@@ -208,7 +216,7 @@ async function saveProfile() {
208216
imageUrl = cleanUrl(props.profile.profileImage)
209217
}
210218
211-
const payload = {
219+
const rawPayload = {
212220
nickname: editableProfile.nickname,
213221
age: editableProfile.age,
214222
region: editableProfile.region,
@@ -218,7 +226,8 @@ async function saveProfile() {
218226
profileImage: imageUrl,
219227
}
220228
221-
// ★ PATCH 한 번만, 그리고 응답으로 스토어 갱신
229+
const payload = sanitizePayload(rawPayload)
230+
222231
const { data: updated } = await patchProfileById(props.profile.memberId, payload)
223232
224233
auth.updateUserProfile(updated)
@@ -227,7 +236,7 @@ async function saveProfile() {
227236
} catch (err) {
228237
console.error('프로필 저장 실패', err)
229238
}
230-
}
239+
}
231240
</script>
232241
<style scoped>
233242
.introduce-box {

0 commit comments

Comments
 (0)