logging message on chrome console in expressjs - MEAN Stack

85 Views Asked by At

I have a created routes and calling some functions in expressjs. This function is properly getting executing and retuning data.

exports.index = function (req, res) {
    Data.find({
    parent: null
  }, function (err, employee) {
    if (err) {
      return handleError(res, err);
    }
    return res.status(200).json(employee);
  });
};

I want to log some message on console when system executes this function. if i use console.log('some message'), I do not see anything on console & if I use alert, I get following error message.

ReferenceError: alert is not defined<br> &nbsp; &nbsp;at exports.index

How can I log messages on chrome console while working with expressjs.

2

There are 2 best solutions below

0
On BEST ANSWER

This is a server site javascript so you need to look at the nodejs console.

0
On

The javascript that's being executed by the code you've provided is executed server-side. Meaning that you will see the console.log output in the node.js console. The google chrome console will only log messages logged from within the html/js sent from the server to the browser.