aurbano / robinhood-node

:chart_with_upwards_trend: NodeJS client for Robinhood Trading :fire:
https://aurbano.github.io/robinhood-node
MIT License
694 stars 184 forks source link

`._set_account()` error - likely for new accounts #57

Closed uladkasach closed 4 years ago

uladkasach commented 7 years ago

I just created an account today w/ Robinhood and it has not been approved yet. This may be the cause of the error.

Code being executed:


var credentials = require("./config/robinhood.json");
var Robinhood = require('robinhood')(credentials, function(){
    console.log(Robinhood.auth_token());
        //      <authenticated alphanumeric token>
});

Expected result

Expected result is to get the token, such as demonstrated in the example

Actual behaviour

Getting this error:

/var/www/git/Trading/workhorse/node_modules/robinhood/src/robinhood.js:149
          _private.account = body.results[0].url;
                                            ^

TypeError: Cannot read property 'url' of undefined
    at Request._callback (/var/www/git/Trading/workhorse/node_modules/robinhood/src/robinhood.js:149:45)
    at Request.self.callback (/var/www/git/Trading/workhorse/node_modules/request/request.js:186:22)
    at emitTwo (events.js:125:13)
    at Request.emit (events.js:213:7)
    at Request.<anonymous> (/var/www/git/Trading/workhorse/node_modules/request/request.js:1163:10)
    at emitOne (events.js:115:13)
    at Request.emit (events.js:210:7)
    at IncomingMessage.<anonymous> (/var/www/git/Trading/workhorse/node_modules/request/request.js:1085:12)
    at Object.onceWrapper (events.js:314:30)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1047:12)
    at _combinedTickCallback (internal/process/next_tick.js:102:11)
    at process._tickCallback (internal/process/next_tick.js:161:9)

and the data returned in the body parameter triggering the error above is

{ previous: null, results: [], next: null }
aurbano commented 7 years ago

Hmm interesting, is it working now after a couple of days?

uladkasach commented 6 years ago

@aurbano certainly is. As soon as the account was approved the error resolved.