【发布时间】:2016-03-11 17:12:16
【问题描述】:
我有一个基本的登录表单,想验证用户的电子邮件是否存在于数据库中,但不确定 angular + node 的语法。
Main.js 我有一个运行此功能的提交按钮上的 ng-click。我从输入中收到电子邮件,不知何故需要将其传递给检查数据库?
$scope.logIn = function() {
var email = $scope.formInfo.email;
$http.get('/findUser').success(function(response){
console.log('find user data');
console.log(response);
});
};
Server.js 我有到数据库的连接,但不确定如何与客户端和后端数据建立连接或语法是什么
app.get('/findUser', function(req, res){
//what do I do here?
db.rejoin_your_ex.find({ email: 'the user's email' }, function(err, docs){
res.json(docs);
});
});
【问题讨论】:
标签: javascript angularjs node.js mongodb authentication