Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use eventbrite javascript sdk installed via npm (node js)

Eventbrite has an official sdk for their API. According to docs, installing and using should be easy:

const eventbrite = require('eventbrite');

// Create configured Eventbrite SDK
const sdk = eventbrite({token: 'OATH_TOKEN_HERE'});

sdk.request('/users/me').then(res => {
    // handle response data
});

However this does not work, I get an error "eventbrite is not a function" when trying to crate the sdk object. In fact, if I log what's in require('eventbrite') this is all I get:

const eventbrite = require('eventbrite');
console.log(JSON.stringify(eventbrite));
// {
//   "PAGE_KEY": "page",
//   "CONTINUATION_KEY": "continuation"
// }

I have probably got something really wrong here, is there an extra step I need to take after installing via npm?

like image 493
Felipe Vignon Avatar asked Jun 22 '26 16:06

Felipe Vignon


1 Answers

I figured it out, for this to work you gotta do:

const eventbrite = require('eventbrite').default;

I figure this has something to do with the way Node is managing requires in later versions (10, in my case).

like image 175
Felipe Vignon Avatar answered Jun 24 '26 15:06

Felipe Vignon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!