Alright, I feel like an idiot because I've done this a thousand times... But I've been battling this for over an hour and about to head to lunch. I'm hoping someone can answer by the time I get back :) I need to compare a password input to what I have stored in the database. When I log the object that I'm sending to the backend in the service, it shows up perfectly, but when I try to send my return object to the backend, I just get an empty object when I log "req.params". I have also tried sending it back with a "POST" instead of a "GET" and logging "req.body" but that also comes in as an empty object. Can someone please tell me what in the heck I am doing wrong? I've done it so many times and feel stupid for having to ask this question but I can't for the life of me figure it out! Thanks in advance! Here is my code
Controller (angular)
$scope.checkOldPassword = function(oldPassword) {
var returnObj = {
oldPassword: oldPassword
}
userSettingsService.checkPassword(returnObj).then(function(response){
console.log(response);
})
}
Service
this.checkPassword = function(oldPassword) {
console.log(oldPassword);
return $http({
method: 'GET',
url: '/api/checkOldPassword',
params: oldPassword
}).then(function(response) {
return response.data;
})
};
Server.js
app.get('/api/checkOldPassword', ensureAuthenticated, UserCtrl.checkOldPassword)
UserCtrl.js (node)
checkOldPassword: function(req, res, next) {
console.log(req.params);
}
via joshbang
No comments:
Post a Comment