Skip to content

Commit

Permalink
change example to async await
Browse files Browse the repository at this point in the history
  • Loading branch information
bhelx committed Oct 8, 2019
1 parent d25e95a commit 40fc317
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions doc/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,25 @@ Keep in mind that the api accepts snake-cased keys but this library expects came
We do the translation for you so this library can conform to js style standards.

```js
client.createAccount({

try {
const acctReq = {
code: 'new-account-code',
firstName: 'Benjamin',
lastName: 'Du Monde'
})
.then(account => console.log(account.id))
.catch(console.log)
}
const account = await client.createAccount(acctReq)
} catch (err) {
if (err && err instanceof recurly.errors.ValidationError) {
// If the request was not valid, you may want to tell your user
// why. You can find the invalid params and reasons in err.params
console.log('Failed validation', err.params)
} else {
// If we don't know what to do with the err, we should
// probably re-raise and let our web framework and logger handle it
console.log('Unknown Error: ', err)
}
}
```

## Pagination
Expand Down

0 comments on commit 40fc317

Please sign in to comment.