1

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

Sateesh K
  • 1,071
  • 3
  • 19
  • 45
  • added a second argument to log message to the second function in the promise and i am getting "undefined" for that argument. – Sateesh K Jun 16 '15 at 03:29

0 Answers0