Skip to content

Commit

Permalink
Merge pull request #267 from limbaba1120/deploy
Browse files Browse the repository at this point in the history
Deploy
  • Loading branch information
limbaba1120 authored Aug 29, 2024
2 parents 6c2b487 + d04af31 commit 739a02f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public ResponseEntity<UserDto.UserUpdateResponse> userUpdate(
) throws IOException {
String email = SecurityContextHolder.getContext().getAuthentication().getName();

if(updateRequest == null && profileImage.isEmpty()){
// profileImage가 null인지도 확인
if (updateRequest == null && (profileImage == null || profileImage.isEmpty())) {
throw ApiUserException.builder()
.category(ApiErrorCategory.RESOURCE_INACCESSIBLE)
.subCategory(ApiUserErrorSubCategory.USER_UPDATE_IMPOSSIBLE)
Expand Down
34 changes: 18 additions & 16 deletions frontend/src/app/_api/myPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,50 +53,52 @@ export async function updateProfileInfo(
},
profileImage?: ProfileImage | null,
) {
const formData = new FormData()
const formData = new FormData();

// updateRequest를 FormData로 추가
const updateRequestBlob = new Blob([JSON.stringify(updateRequest)], {
type: 'application/json',
})
formData.append('updateRequest', updateRequestBlob) // JSON 데이터를 문자열로 변환하여 추가
});
formData.append('updateRequest', updateRequestBlob);

// profileImage가 있을 경우 FormData로 추가
if (profileImage) {
formData.append('profileImage', profileImage.blob)
formData.append('profileImage', profileImage.blob);
}

const requestUrl = `${API_PRIVATE_URL}/user/update`
const requestUrl = `${API_PRIVATE_URL}/user/update`;

const res = await fetch(requestUrl, {
method: 'PATCH',
credentials: 'include',
body: formData,
})
});

if (!res.ok) {
const errorBody = await res.json()
throw new ApiError(res.status, errorBody)
const errorBody = await res.json();
throw new ApiError(res.status, errorBody);
}

return await res.json()
return await res.json();
}

export async function updateProfileImg(profileImage: File) {
const formData = new FormData()
formData.append('profileImage', profileImage)
const requestUrl = `${API_PRIVATE_URL}/user/update`
const formData = new FormData();
formData.append('profileImage', profileImage);
const requestUrl = `${API_PRIVATE_URL}/user/update`;

const res = await fetch(requestUrl, {
method: 'PATCH',
credentials: 'include',
body: formData,
})
});

if (!res.ok) {
const errorBody = await res.json()
throw new ApiError(res.status, errorBody)
const errorBody = await res.json();
throw new ApiError(res.status, errorBody);
}

return await res.json()
return await res.json();
}

export async function getMyPosts(): Promise<myPostAllResponse[]> {
Expand Down

0 comments on commit 739a02f

Please sign in to comment.