title: How can i check a JWT token is valid using an async function route with nodejs?
body: <p>I am following the guide below to verify that only registered users can send requests to my backend nodejs server, my frontend is sending requests with an authorization header that contains a token and that part is working well. The nodejs backend should then check the token is valid before sending a response:
  <a href="https://www.tonyvu.co/posts/jwt-authentication-node-js" rel="nofollow noreferrer">https://www.tonyvu.co/posts/jwt-authentication-node-js</a></p>
  <p>The example shows i should add 'AuthenticateJWT' like the following to my route:</p>
  <pre><code>app.post(“/api/token”, authenticateJWT, (req, res) =&gt; {
  ...
  });
  </code></pre>
  <p>However my route is an async function and i can't find the correct syntax to add it. My code is the following:</p>
  <pre><code>router.post('/account/user_load_balance',  async function (req, res) {
  
   ...  
  });
  </code></pre>
  <p>I have tried the following:</p>
  <pre><code>router.post('/account/user_load_balance',  async function, authenticateJWT (req, res)     try {
   ...
  });
  </code></pre>
  <p>but this gives me an error:</p>
  <pre><code>Unexpected token ','
  </code></pre>
  <p>what is the correct syntax?</p>