You just need to parse req.query.data
into a number; you can use parseInt
for that. But you also need to convert docs[0]
to a string before passing it to res.end
:
db.stories.find({"SOLUTION_TEST Feature" : parseInt(req.query.data, 10)},function(e,docs){
console.log(docs);
if(docs[0]){
res.end(JSON.stringify(docs[0]));
}
else{
res.end();
}
});