I've two app.use
statements and would like to use each for different routes.
app.use(function(request, response, next){ //also has /sessions/:id etc.
if(request.url.indexOf("/sessions") == 0) {
console.log('in sessions', request.url); //executes for both routes
} else {
next();
}
});
app.use(function(request, response, next){
if(request.url.indexOf("/sessions-speakers") == 0) {
console.log('in sessions speakers', request.url);
} else {
next();
}
});
but the problem is with checking url is that first app.use
and it's condition gets true in both cases, I'm wondering what can I use to branch there based on the routes.
Expectation:
Work out something using if statement in app.use to branch out between the two requests.