Skip to content

Commit

Permalink
feat: Improved payment user migrations to consider delay (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
chavda-bhavik authored Jun 21, 2024
2 parents 545cb42 + 315bb64 commit e1ab56f
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ export async function run() {

if (users.length > 0) {
// eslint-disable-next-line no-console
for (const user of users) {
await paymentAPIService.createUser({
email: user.email,
externalId: user.email,
name: `${user.firstName} ${user.lastName}`,
});
}
await Promise.all(
users.map(async (user) => {
try {
await paymentAPIService.createUser({
email: user.email,
externalId: user.email,
name: `${user.firstName} ${user.lastName}`,
});
await new Promise((resolve) => setTimeout(resolve, 1000));
} catch (error) {
console.error(error);
}
})
);
}

// eslint-disable-next-line no-console
Expand Down

0 comments on commit e1ab56f

Please sign in to comment.