title: How to use async, await in React
body: <p>I'm trying to make my code simple and I would like to use async and await for the code below. however, I don't know how to imply...It'd be nice to have some example codes.</p>
  
  <pre><code>deletePost = (post) =&gt; {
      var post_id = post;
  
      try {
          axios.delete(`http://localhost:4000/deleteAll/comments/${post_id}`)
              .then(() =&gt; {
                  axios.delete(`http://localhost:4000/posts/${post_id}`);
              }).then(() =&gt; {
                  axios.get('http://localhost:4000/posts')
                 .then(({data}) =&gt; {
                      this.setState({
                          posts: data.result
                      })
                  })
              })
      }
      catch(err) {
          console.error(err);
      }
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>// This is what i understand so far.
  deletePost = async(post) =&gt; {
      var post_id = post;
      try {
          var deleteComments = await axios.delete(`http://localhost:4000/deleteAll/comments/${post_id}`);
          var deletePost = await axios.delete(`http://localhost:4000/posts/${post_id}`);
          var getPost = await axios.get('http://localhost:4000/posts'); // How can I change the state here??          
          // return ??
      }
      catch {
         ...
      }
  }
  </code></pre>