mjesuele / gemini-api-node

Node.js client for the Gemini cryptocurrency exchange API
26 stars 17 forks source link

Fixes documentation, missing .default #2

Closed dsousadev closed 6 years ago

mjesuele commented 7 years ago

Interesting -- that actually doesn't work for me. What's your environment?

mjesuele commented 7 years ago

...Also, thanks for contributing :)

dsousadev commented 7 years ago

No problem :) when running it with Node.js I had to use .default

mjesuele commented 7 years ago

Oooh, yeah, if you're not using ES6+ imports then I suppose that is how it works:

> var GeminiAPI = require('gemini-api')
undefined
> GeminiAPI
{ default: { [Function: GeminiAPI] WebsocketClient: [Function: GeminiAPIWebsocketClient] } }

But this is an error:

import GeminiAPI from 'gemini-api';
const websocket = new GeminiAPI.default.WebsocketClient(params);

because default is undefined here.

If we're going to change the docs, perhaps we need two examples, one for ES6 modules and one for require. But there's probably also a way to export the module so that the default is not needed when using require, so that'd probably be best. I can look into it, or feel free to yourself!

mjesuele commented 6 years ago

@dsousadev gonna close this, let me know if you'd like to reopen -- or I might do it myself.