This is strange. I am passing 2 empty arrays in my payload and the post call is failing.If I pass only 1 empty array, then the call is successful.
I am using Express: ^4.13.0
.
Angular Code :
$scope.login = function(){
var temp = {};
temp.username = $scope.username;
temp.password = $scope.password;
temp.speed=[]; // <---- code works without this line
temp.notification=[];
loginService.login(temp).then(function(data){
$state.transitionTo('root.dashboard');
}, function(error) {
console.log("error" , error);
$scope.message = error.data.message;
});
}
Node Route :
app.post('/connect/local', User.login);
I am using passport for login strategy.
In the server, I get this error
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:335:11)
at ServerResponse.header (c:\workspace\HotOrNot\node_modules\express\lib\response.js:718:10)
at c:\workspace\HotOrNot\main\app\modules\api\User.js:154:13
at Strategy.strategy.success (c:\workspace\HotOrNot\node_modules\passport\lib\middleware\authenticate.js:194:18)
at verified (c:\workspace\HotOrNot\node_modules\passport-local\lib\strategy.js:83:10)
at c:\workspace\HotOrNot\main\app\config\pass.js:52:24
at Query.<anonymous> (c:\workspace\HotOrNot\node_modules\mongoose\lib\model.js:3343:16)
at c:\workspace\HotOrNot\node_modules\mongoose\node_modules\kareem\index.js:244:21
at c:\workspace\HotOrNot\node_modules\mongoose\node_modules\kareem\index.js:127:16
at doNTCallback0 (node.js:407:9)
at process._tickCallback (node.js:336:13)
Any clue will help.