dijs / wiki

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

How to make this chaining work? #163

Closed BSiddharth closed 2 years ago

BSiddharth commented 2 years ago

I am trying to do something like this.

  const result = await (await wiki().page("Batman"))
    .chain()
    .summary()
    .content()
    .mainImage()
    .request();

Error:

(node:70868) UnhandledPromiseRejectionWarning: TypeError: (intermediate value).chain(...).summary(...).content(...).mainImage is not a function
dijs commented 2 years ago

mainImage is not supported when using query chain. Please take a look at the docs: https://dijs.github.io/wiki/QueryChain.html

BSiddharth commented 2 years ago

@dijs Thankyou for responding. I went through the docs and noticed that. image() kind of works for some pages but for most it does not work (example batman). And .chain().content().request(); Useful for extracting structured section content too is not structured like it is when called independently in const content = await page.content();

dijs commented 2 years ago

Unfortunately, the underlying request the chain image function uses is much simpler than the mainImage function. So this currently works with some pages and not others. Not exactly sure why yet.