January 2018
Beginner
658 pages
13h 10m
English
Inside app.use, we're going to get started by creating a logger that will log out all of the requests that come in to the server. We'll store a timestamp so we can see exactly when someone made a request for a specific URL.
To get started inside the middleware, let's get the current time. I'll make a variable called now, setting it equal to newDate, creating a new instance of our date object, and I'll call it toString method:
app.use((req, res, next) => { var now = new Date().toString(); next();});
The toString method creates a nice formatted date, a human-readable timestamp. Now that we have our now variable in place, we can start creating the actual logger by calling console.log.
Let's call console.log, passing in whatever ...
Read now
Unlock full access