I used this tutorial to make a login page. My angular code looks like this.
app.directive('ensureUnique', ['$http', function($http) {
console.log("In validate");
return {
require : 'ngModel',
link : function(scope, ele, attrs, c) {
scope.$watch(attrs.ngModel, function() {
$http({
method : 'POST',
url : '/email/check/' + scope.$eval(attrs.ensureUnique),
data : { 'field' : attrs.ensureUnique}
}).success(function(data, status, headers, cfg){
c.$setValidity('unique', data.isUnique);
}).error(function(data, status, headers, cfg) {
c.$setValidity('unique', false);
});
});
}
}
}]);
and my routes file i.e index.js is like this.
app.post('/email/check/:email', function(req, res, next){
console.log(req.query);
});
Now i want to see this data on my Node application, so that I can verify if my email Id is unique. But I am unable to see it. It always gives me a blank object. I consulted many SO post and docs but couldn't find any answer. What is the error here? What am I missing?