2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-24 14:04:14 +03:00

Added a simple async/await example

Since `async/await` is not widely used, and I have seen quite a few questions on how to actually use `async/await` with Axios, I figured it would be nice to have it in the readme, front and center.
This commit is contained in:
Deric Cain
2018-01-08 06:15:16 -06:00
committed by GitHub
parent db44a8f316
commit d8cce2017d
+8
View File
@@ -73,6 +73,14 @@ axios.get('/user', {
.catch(function (error) {
console.log(error);
});
// Want to use async/await?
try {
const response = axios.get('/user?ID=12345');
console.log(response);
} catch (error) {
console.log(error);
}
```
Performing a `POST` request