I'm trying to get a count of users with the email [email protected] via the ajax below:
function getCount(event) {
event.preventDefault();
var queryCount = {
email:'[email protected]'
}
$.ajax({
type: 'GET',
data: queryCount,
url: '/countuser',
dataType: 'JSON'
}).done(function(response) {
//Check for successful (blank) response
if(response.msg === '') {
} else {
}
});
}
and this in users.js:
exports.countuser = function(db) {
return function(req, res) {
db.collection('userlist').find(req.body).count(function(err,count) {
res.send(count);
});
}
};
but this isn't working (getting the count of the complete user list, which makes me think that req.body is empty). What would be a correct way of going about this?
req.bodyempty andreq.paramspopulated with your data?app.getroute look like?app.get('/countuser/:email'and then checkreq.params