I am using nodejs modules reqwest and when for making the remote calls and the promise returned is a failure.
How ever when i use postman to submit the same request i am getting the response back.
I am not sure why the promise is getting rejected.
Here is my code.
login(username, password) {
return this.handleAuth(
when(
request(
{
url: LOGIN_URL,
method: 'POST',
crossOrigin: true,
type: 'json',
data: {
username,
password
}
}
)
)
);
}
handleAuth(loginPromise) {
return loginPromise
.then(function(response) {
console.log('response=['+JSON.stringify(response)+']');
if(response && response.responseText){
var jwt = response.responseText;
if(jwt && jwt.trim()!=''){
console.log('response.data=['+JSON.stringify(jwt)+']');
LoginActions.loginSuccessful(jwt);
}
return true;
}
return true;
}
,function(error){
console.log('Error =['+error+']');
});
}
Thanks