'a use method of express.js called twice
I had a very simple node.js project with express.js library set up for my project. I found that the middleware implemented using express().use() was called twice when I made a request to the nodejs server.
The following is the code-snap of the express library using and implementing middleware layer.
const express = require('express');
const app = express();
app.use((req, res, next) => {
console.log('This is a middleware layer!');
res.send('hello from express.');
});
module.exports = app;
May I know if there was any thing going wrong? Thanks a lot.
The following screen capture shows the console.log run twice.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|