binary-live-api NodeJS error

This is my first approach to use de binary-live-api with NodeJS.

Using the following code as a starting point, I got a "event.js:183 throw er; // Unhandled 'error' event"

var ws = require('ws');
var LiveApi = require('binary-live-api').LiveApi;

var api = new LiveApi({ websocket: ws });

const token = '"-- token removed here --";
console.log(token);
api.authorize(token).then(
() => console.log('Authorized!'),
() => console.log('Not Authorized')
);

The complete output on the terminal is:

events.js:183
throw er; // Unhandled 'error' event
^

Error: Unexpected server response: 401
at ClientRequest.req.on (/Users/raimar/Documents/Code/Binary/node_modules/ws/lib/websocket.js:535:5)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:543:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:112:17)
at TLSSocket.socketOnData (_http_client.js:440:20)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
Raimars-iPro:Binary raimar$

Suggestions ?

Thanks

Best Answer

Answers

Sign In or Register to comment.