I am trying to make a Get request to search a database by object ID. When I write
router.get('/getPoll/:id', function(req, res) {
Poll.findOne({id: req.params.id}, function(err, foundPoll) {
if(err) throw err;
if(!foundPoll) {
res.json('Cant find poll');
} else {
res.json(foundPoll);
}
});
});
...instead of using the correct url which contains an object id, the request url literally contains ":id"
I want to use a url like: "/getPoll/123456789asdf34
But a url like: "/getPoll/:id"
is used instead
The rest of the code can be found on github here
via Ethernetz
No comments:
Post a Comment