I
I
igorianru2017-04-30 12:02:47
Node.js
igorianru, 2017-04-30 12:02:47

Features of app.use in express or what am I doing wrong?

Hi, I'm adding code to app.js, it was expected that I would see Time1 and Time2 in the console, but I see only Time1. How to make Time2 run?
Similarly, if you change app.use('*', to app.route('*'), the result will be the same.

app.use((req, res, next) => {
  console.log('Time1: %d', Date.now());
  next();
});

app.use('*', (req, res, next) => {
  app.use((req, res, next) => {
    console.log('Time2: %d', Date.now());
    next();
  });

  next()
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question