title: UnhandledPromiseRejectionWarning: This error originated either by throwing inside of an async function without a catch block
body: <p>I am getting following error in my Node-Express App </p>
  
  <blockquote>
    <p>UnhandledPromiseRejectionWarning: Unhandled promise rejection. This
    error originated either by throwing inside of an async function
    without a catch block, or by rejecting a promise which was not handled
    with .catch(). (rejection id: 4)</p>
  </blockquote>
  
  <p>To say the least, I have created a helper function which looks something like this </p>
  
  <pre><code>const getEmails = (userID, targettedEndpoint, headerAccessToken) =&gt; {
      return axios.get(base_url + userID + targettedEndpoint,  { headers: {"Authorization" : `Bearer ${headerAccessToken}`} })
      .catch(error =&gt; { throw error})
  }
  </code></pre>
  
  <p>and then I am importing this helper function </p>
  
  <pre><code>const gmaiLHelper = require("./../helper/gmail_helper")
  </code></pre>
  
  <p>and calling it inside my api route like this</p>
  
  <pre><code>router.get("/emailfetch", authCheck, async (req, res) =&gt; {
    //listing messages in users mailbox 
    let emailFetch = await gmaiLHelper.getEmails(req.user._doc.profile_id , '/messages', req.user.accessToken)
    .catch(error =&gt; { throw error})
    emailFetch = emailFetch.data
    res.send(emailFetch)
  })
  </code></pre>
  
  <p>From my end, I think I am handling the error by using catch block. </p>
  
  <p><strong>Question:</strong> Can someone explain me why I am getting the error and how can I fix it?</p>