Skip to content

Commit

Permalink
🐛 fix async bug
Browse files Browse the repository at this point in the history
* 배열에 푸시하는 작업이 비동기로 이루어지는 것을 동기적으로 하도록 수정함
  • Loading branch information
KMUlee committed May 10, 2024
1 parent 13a070a commit 6a71920
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/configs/typeorm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getTypeOrmConfig = (
synchronize: true,
autoLoadEntities: true,
namingStrategy: new SnakeNamingStrategy(),
logging: true,
logging: false,
extra: {
timezone: 'UTC',
},
Expand Down
12 changes: 6 additions & 6 deletions src/profile/profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ export class ProfileService {
if (!profile) {
return null;
}

// 내가 좋아요를 누른 사람을 찾는 로직
const likedProjects: ProfileDto[] = [];
const likedList = await this.userService.getLikedList(userId);
likedList.forEach(async (id) => {
for (const id of likedList) {
const likedProfile = await this.profileRepository.findOneBy({ id });
likedProjects.push(likedProfile);
});
}
// 좋아요를 누른 사람을 찾는 로직
const likedByUsers: ProfileDto[] = [];
const likedUserIdList = await this.likesService.getLikedUserIdList(
profile.id,
);
console.log(likedUserIdList);
likedUserIdList.forEach(async (id) => {
for (const id of likedUserIdList) {
const likedProfile = await this.profileRepository.findOne({
where: {
user: {
Expand All @@ -68,7 +68,7 @@ export class ProfileService {
relations: ['user'],
});
likedByUsers.push(likedProfile);
});
}
const profileData: GetProfileDto = {
profile,
likedProjects,
Expand Down

0 comments on commit 6a71920

Please sign in to comment.