Skip to content

Commit

Permalink
adding await to catch errors (#219)
Browse files Browse the repository at this point in the history
adding await to catch errors
  • Loading branch information
abhipillai authored Oct 20, 2023
1 parent 0438dd7 commit 1b99bfa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions public/examples/ach.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
throw new Error(errorBody);
}

function tokenize(paymentMethod, options = {}) {
async function tokenize(paymentMethod, options = {}) {
paymentMethod.addEventListener(
'ontokenization',
async function (event) {
Expand All @@ -65,7 +65,7 @@
}
}
);
paymentMethod.tokenize(options);
await paymentMethod.tokenize(options);
}

// status is either SUCCESS or FAILURE;
Expand Down Expand Up @@ -139,7 +139,7 @@

try {
achButton.disabled = true;
tokenize(paymentMethod, options);
await tokenize(paymentMethod, options);
} catch (e) {
achButton.disabled = false;
displayPaymentResults('FAILURE');
Expand Down

0 comments on commit 1b99bfa

Please sign in to comment.