i'm new in node and i'm trying to add and delete routes "on the fly" in Express 4. I'm adding them using app.use(path,route) and i'm able to locate them in the app._router.stack Array but i'm not able to delete a particular router. Is it possible? I've tried with app._router.stack.splice(myRouterIndex,1) without success.
Here is my example:
for (var i = 0; i < app._router.stack.length; i++) {
if(app._router.stack[i].name=='router') {
console.log(app._router.stack[i].name);
app._router.stack.splice[i,1];
console.log(app._router.stack);
break;
}
}
The second console.log(app._router.stack) prints exactly the same as the first one.