jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
MIT License
1.58k stars 768 forks source link

TypeError: binance.options is not a function #678

Open Martinek16 opened 3 years ago

Martinek16 commented 3 years ago

Unable to run getting started code, running the code will return message 'TypeError: binance.options is not a function'.

Reinstall of npm package did not solve this issue. Do I need to define the options function separately?

code

const Binance = require('node-binance-api');
const binance = new Binance().options({
  APIKEY: '<key>',
  APISECRET: '<secret>'
});

result

PS C:\Users\marti\Desktop\cryptobot> node bot.js
C:\Users\marti\Desktop\cryptobot\bot.js:415
client.login(process.env.BOT_TOKEN)
^

ReferenceError: client is not defined
    at Object.<anonymous> (C:\Users\marti\Desktop\cryptobot\bot.js:415:1)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47
ahmadmustafeen commented 3 years ago

instead of this: const Binance = require('node-binance-api');

use this: const Binance = require('node-binance-api').default;