Categories
JavaScript Answers

How to make axios synchronous with JavaScript?

Spread the love

Sometimes, we want to make axios synchronous with JavaScript.

In this article, we’ll look at how to make axios synchronous with JavaScript.

How to make axios synchronous with JavaScript?

To make axios synchronous with JavaScript, we use the await keyword.

For instance, we write

const response = await axios.get("/api/persons/unique/alias");

to call axios.get to make a get request and return a promise with the response.

Then we use await to wait for the response and get it.

Conclusion

To make axios synchronous with JavaScript, we use the await keyword.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *