Error Event
Closed this issue · 11 comments
Hi There,
I keep getting the error below when running this. Any suggestions?
events.js:187
throw err;
^
Error: Unhandled "error" event. ([object Object])
at Questrade.emit (events.js:185:19)
at C:\D-Drive\node_modules\questrade\index.js:43:28
at Request._callback (C:\node_modules\questrade\index.
js:107:14)
at Request.self.callback (C:\node_modules\request\requ
est.js:186:22)
at emitTwo (events.js:125:13)
at Request.emit (events.js:213:7)
at Request. (C:\node_modules\request\reques
t.js:1163:10)
at emitOne (events.js:115:13)
at Request.emit (events.js:210:7)
at IncomingMessage. (C:\node_modules\reques
t\request.js:1085:12)
What is the code?
@jeremysy Have you seen this? #3 (comment) I had a similar issue on the Questrade side of things.
@jonathanbell I did see that and was having trouble following the thread. It looks like one of @leanderlee comments are missing. What did you do to resolve it?
@leanderlee below is my code and thanks for pulling this together. Looks like it once I have it working it will take care of everything I need:
var Questrade = require('questrade');
var qt = new Questrade(xxxxxxx);
qt.on('ready', function () {
qt.getAccounts()
qt.getBalances()
qt.getQuote('MSFT')
})
I was able to get the code below working. How do I make it show the results in my console?The console says logged in but the next line is blank.
var Questrade = require('questrade');
var qt = new Questrade('Da8AyC3MsJCOSiXzp7_wddK7UmzE0v5L-s0');
qt.on('ready', function() {
console.log('logged in!');
qt.getAccounts(function (err, accounts) {})
});
Just FYI, I would reset your application key (Da8AyC3MsJCOSiXzp7_wddK7UmzE0v5L-s0) as it has just been exposed to the Internet.
No offence intended, but this is basic NodeJS programming. You may want to bone up a little on handling callbacks in Node first of all.
var Questrade = require('questrade');
var qt = new Questrade('Da8AyC3MsJCOSiXzp7_wddK7UmzE0v5L-s0');
qt.on('ready', function() {
console.log('Logged in!');
qt.getAccounts(function (err, accounts) {
if (err) {
// Do something with/about the error..
console.error('There was an error...', err);
}
console.log('getAccounts() worked! Hurray!', accounts);
});
});
Node follows an "error first" callback pattern. Hence the function (err, accounts){}
where err
is the error and accounts
is the data (in this case).
@leanderlee I'd purpose closing this and #3
No clue.
But I think you meant to conjure @jonathanbell