Skip to content

Commit

Permalink
Dont fail on 404 (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlyrl authored Jan 30, 2021
1 parent 7973fb5 commit f6cdce9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/controllers/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,16 @@ export const updateUsernames = async (req: Request, res: Response): Promise<void
url: DISCORD_URL + '/user/' + user.discordId
};

const response = await axios(url);
if(response.status == 200 && response.data?.username) {
user.discordUsername = response.data.username;
await userRepo.save(user);
try {
const response = await axios(url);
if(response.status == 200 && response.data?.username) {
user.discordUsername = response.data.username;
await userRepo.save(user);
}
} catch (e) {
console.log('Failed to update user with discord ID: ' + user.discordId);
}
}

res.sendStatus(200);

}

0 comments on commit f6cdce9

Please sign in to comment.