Skip to content

Commit

Permalink
Merge pull request #1276 from dericcain/patch-1
Browse files Browse the repository at this point in the history
Added a simple async/await example
  • Loading branch information
emilyemorehouse committed Feb 23, 2018
2 parents a105872 + 3ca0499 commit d4dc124
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -74,8 +74,21 @@ axios.get('/user', {
.catch(function (error) {
console.log(error);
});

// Want to use async/await? Add the `async` keyword to your outer function/method.
async function getUser() {
try {
const response = await axios.get('/user?ID=12345');
console.log(response);
} catch (error) {
console.error(error);
}
}
```

> **NOTE:** `async/await` is part of ECMAScript 2017 and is not supported in Internet
> Explorer and older browsers, so use with caution.
Performing a `POST` request

```js
Expand Down

0 comments on commit d4dc124

Please sign in to comment.