dijs / wiki

Wikipedia Interface for Node.js
MIT License
315 stars 61 forks source link

Usage from Node #43

Closed arliber closed 7 years ago

arliber commented 7 years ago

Hi, I'd love to use wiki from Node 6.9 but since it doesn't support import I tried to use require instead.

Unfortunately, I got an error wiki is not a function.

let wiki = require('wikijs');

wiki().page('batman')
          .then(page => page.summary())
          .then(summary => {
            // some action
          })

I also tried wiki.page but got 'wiki.page' is not a function.

Does it strictly require next node version? Thanks

dijs commented 7 years ago

Use const wiki = require('wikijs').default

I do not believe Node v6 has import yet. Possibly v7 has them. And you can always use them with Babel.

Mechasparrow commented 7 years ago

I second @dijs statement

dijs commented 7 years ago

I'm sure there is a way to compile the library where ES6 imports AND require can be used interchangeably, but I have not had time to research that yet...

If someone would like to figure that out, I would be more than happy to implement it.