Answer the question
In order to leave comments, you need to log in
How to run 2 middlware for one request url?
var express = require('express');
var app = express();
var mw1 = function(req, res){
res.send('Hello')
next();
}
var mw2 = function(req, res){
res.send('world')
}
app.get('/', mw1, mw2);
app.listen(3030)'
Answer the question
In order to leave comments, you need to log in
Sorry, let's rephrase the question. The code should display the 'hello world' page with 2 functions. here is the code that outputs only 'hello', what needs to be fixed? Thank you, if you can show on my example);
PS Added next to mw1 argument
var express = require('express');
var app = express();
var mw1 = function(req, res, next){
res.send('Hello')
next('mw2');
}
var mw2 = function(req, res){
res.send('world')
}
app.get('/', mw1, mw2);
app.listen(3030)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question