revolunet / node-sellsy

Node Sellsy API wrapper
https://github.com/revolunet/node-sellsy
MIT License
17 stars 7 forks source link

TypeError: Sellsy is not a constructor #13

Open TTalex opened 2 years ago

TTalex commented 2 years ago

Hey,

It looks like last November commits broke the example code in Nodejs.

var Sellsy = require("node-sellsy");

var sellsy = new Sellsy({
  creds: {
    consumerKey: "myConsumerKey",
    consumerSecret: "myConsumerSecret",
    userToken: "myUserToken",
    userSecret: "myUserSecret",
  },
});

Outputs TypeError: Sellsy is not a constructor

Example on runkit (node v17.3.1, node-sellsy v1.5.5): https://runkit.com/embed/ua0v5yaqhk9c

Adding .default to the require seems to fix the issue for now.

var Sellsy = require("node-sellsy").default;

I'm guessing something changed with the exports ?

simon-tannai commented 2 years ago

@TTalex I'm using TypeScript, import Sellsy from 'node-sellsy'; is working fine. Did you tried to use ES6 import keyword ?

TTalex commented 2 years ago

@simon-tannai No issues with import indeed, but the quickstart tutorial does use the require call, so maybe it's a documentation problem ?