title: GUMROAD license verification API with NodeJs
body: <p>I have the below middleware function which controls my user register page.</p>
  <p>in the specific the below function is able to:</p>
  <ul>
  <li>recognizes if the user insert an email that is already in database;</li>
  <li>recognizes if the password and password confirm coincide;</li>
  <li>and, consuming the Gumroad API is recognizing if the licensekey insert is valid or not;</li>
  </ul>
  <p>I just added the code for the gumroad API for license key verification, is working, but on terminal I got the following error:</p>
  <p>(node:23536) UnhandledPromiseRejectionWarning: TypeError: req.next is not a function
  at done (C:\Users\CESARE\User-Management-Tutorial\node_modules\express\lib\response.js:1007:25)
  at ExpressHandlebars.renderView (C:\Users\CESARE\User-Management-Tutorial\node_modules\express-handlebars\lib\express-handlebars.js:244:4)
  (node:23536) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag
  <code>--unhandled-rejections=strict</code> (see <a href="https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode" rel="nofollow noreferrer">https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode</a>). (rejection id: 18)</p>
  <p>Here below the authController.js file:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>exports.register = (req, res) =&gt; {
      // Destructor
      const { name, email, password, passwordConfirm, licencekey } = req.body;
  
      var url = "https://api.gumroad.com/v2/licenses/verify";
  
      var xhr = new XMLHttpRequest();
      xhr.open("POST", url);
  
      xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  
      xhr.onreadystatechange = function () {
          if (xhr.readyState === 4) {
          
              console.log(xhr.responseText);
  
          }
  
        
          
  
  
          connection.query('SELECT email FROM login WHERE email = ?', [email], async (error, results) =&gt; {
            
              if (error) {
                  console.log(error);
              }
              if (results.length &gt; 0) {
                  return res.render('register', {
                      message: 'That email is already in use'
                  })
              } else if (password !== passwordConfirm) {
                  return res.render('register', {
                      message: 'Password do not match'
                  });
              }  
  
              let hashedPassword = await bcrypt.hash(password, 8);
  
  
              connection.query('INSERT INTO login SET ?', { name: name, email: email, password: hashedPassword }, (error, results) =&gt; {
                  if (error) {
                      console.log(error);
                  } else {
                      return res.render('register', {
                          message: 'User registered'
                      });
  
                  }
              })
  
          });
        
          if (xhr.status != 200) {
              return res.render('register', {
                  message: 'License number not valid'
              })
          }
      }
     
      var data = "product_permalink=dpduj" + "&amp;" + "license_key=" + `${licencekey}`
      xhr.send(data);
  
  };</code></pre>
  </div>
  </div>
  </p>
  <p>Any advise/direction on how to remove this error are highly appreciated, thank you!</p>