dijs / wiki

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

Can not read redirects #49

Closed nnnikolay closed 7 years ago

nnnikolay commented 7 years ago

In case of the following usage

 wiki().page(data)
      .then(page => {
        console.log(page.info());
      })
      .then(console.log('Info box is parsed'))
      .catch(e => console.error(e));

in that case, I receive the following error:

TypeError: Cannot read property 'redirects' of undefined
    at a (... node_modules/wikijs/src/wiki.js:32:9)

I've installed wikijs@3.1.0 version

dijs commented 7 years ago

Can you give me the wiki page name that was failing, so I can reproduce?

nnnikolay commented 7 years ago

Sure, the data variable has following value - March.

But I've tried different words/cities in my case the result is the same. After some debugging I've found that in handeRedirect method the res argument has following object

{ batchcomplete: '' }
nnnikolay commented 7 years ago

Ok, it looks like I've found what was the reason, the querystring package can not deal with the stream byte. So I had to explicitly do .toString() for my data. Thanks!

dijs commented 7 years ago

Glad you figured it out!