Skip to content

Commit

Permalink
Clarify async/await a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
rattrayalex-stripe committed Dec 24, 2019
1 parent 5642eb2 commit 578a768
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,30 @@ The package needs to be configured with your account's secret key which is
available in your [Stripe Dashboard][api-keys]. Require it with the key's
value:

<!-- prettier-ignore -->
```js
const stripe = require('stripe')('sk_test_...');

stripe.customers.create({
email: '[email protected]',
});
})
.then(customer => console.log(customer.id))
.catch(error => console.error(error));
```

Or using ES modules, this looks more like:
Or using ES modules and `async`/`await`:

```js
import Stripe from 'stripe';
const stripe = new Stripe('sk_test_...');
//

(async () => {
const customer = await stripe.customers.create({
email: '[email protected]',
});

console.log(customer.id);
})();
```

### Usage with TypeScript
Expand Down

0 comments on commit 578a768

Please sign in to comment.