Use Async/Await with Axios in React.js
Following How to use async/await with axios in react I am trying to make a simple get request to my server using Async/Await in a React.js App. The server loads a simple JSON at /data which looks like this JSON { id: 1, name: "Aditya" } I am able to get the data to my React App using simple jquery ajax get method. However, I want to make use of axios library and Async/Await to follow ES7 standards. My current code looks like this: class App extends React.Component{ async getData(){ const res = await axios('/data'); console.log(res.json()); } render(){ return( <div> {this.getData()} </div> ); }