This is my signup.js file.

module.exports.signup = function(req, res) {
  sql.connect(webconfig, function(err) {
    if (err) console.log(err);
    var request = new sql.Request();
    request.query(
      `
      select * from UsernamesTable;
      `,
      function(err, data) {
        if (err) {
          console.log(err);
        }
        res.render('signup', { usernames: data.recordset }); //here
        sql.close();
      }
    );
  });
};

This is my signup.ejs file

<html>
.
.
<script>
   console.log(usernames); // here
</script>
</html>

I want to catch usernames value in my ejs file. But it doesn't return anything.. console.log(<%= usernames %>) does not work also.

0 Answers