0

This is my first question here on Stack so maybe I'll miss something since I'm not used to ask these kind of stuff.

I'm trying to implement poloniex-api-node into Node-Red. However everytime I run my code I get "TypeError: Poloniex is not a constructor".

I have added the following code to my settings.js to make this external module available:

 functionGlobalContext: 
{    poloniex: require('poloniex-api-node') },

Then in a function node I'm using the code:

const Poloniex = context.global.get('poloniex-api-node');
let poloniex = new Poloniex();

poloniex.returnTicker((err, ticker) => {
  if (err) {
    console.log(err.message);
  } else {
    console.log(ticker);
  }
});

I have an inject Node to trigger this but I'm always getting the error above. My experience with Node and Javascript is almost null so go easy :D

Best Regards

jmduarte
  • 3
  • 1

1 Answers1

1

You have a typo in the function node, you stored the reference under poloniex and you are trying to retrieve poloniex-api-node.

const Poloniex = context.global.get('poloniex-api-node');
let poloniex = new Poloniex();

should be

const Poloniex = context.global.get('poloniex');
let poloniex = new Poloniex();
hardillb
  • 54,545
  • 11
  • 67
  • 105