Created
August 1, 2013 13:10
-
-
Save dominykas/6131160 to your computer and use it in GitHub Desktop.
req.params get overwritten
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For http://localhost:3000/1 the following output will be produced: | |
Matched /:id | |
[ id: '1' ] | |
Matched /* | |
[ '1' ] | |
Timeout in /:id | |
[ '1' ] | |
Notice how req.params inside the /:id handler has changed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = require('express')(); | |
app.get('/:id', function(req, res, next) { | |
console.log("Matched /:id"); | |
console.log(req.params); | |
setTimeout(function () { | |
console.log("Timeout in /:id"); | |
console.log(req.params); | |
}, 100); | |
next(); | |
}); | |
app.get('/*', function(req, res) { | |
console.log("Matched /*"); | |
console.log(req.params); | |
res.send("OK"); | |
}); | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment