I've got the following node/express code:
app.get("/notes/:categoryName", function (res, req) {
var categoryName = req.params.categoryName;
res.render("notes", {title: categoryName});
});
But when I look at req.params, it's undefined.
Yet, in another controller it works fine:
app.get("/api/notes/:categoryName", function (req, res) {
var categoryName = req.params.categoryName;
data.getNotes(categoryName, function (err, notes) {
if (err) {
res.send(400, err);
} else {
res.set("Content-Type", "application/json");
res.send(notes.notes);
}
});
});
What's the deal?
app.get("/notes/:categoryName", function (res, req) {
More attention :
app.get("/notes/:categoryName", function (req, res) {
You switched the params (res, req)