mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +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:
@@ -73,6 +73,14 @@ axios.get('/user', {
|
|||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
console.log(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
|
Performing a `POST` request
|
||||||
|
|||||||
Reference in New Issue
Block a user