dijs / wiki

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

Is it possible to chain requests? #159

Closed vin-ni closed 2 years ago

vin-ni commented 2 years ago

Is it possible to combine requests? I've read in the wiki api that it's recommended to combine queries as much as possible to save on requests.

Something like this for example: wiki.page('batman').then(page => page.chainedRequest(['content', 'coordinates', 'summary'])).then(console.log);

Thank you!

dijs commented 2 years ago

Not yet, but that is a great idea. Can you provide any raw wikipedia api examples?

vin-ni commented 2 years ago

I combined some things in the Sandbox:

Direct query: https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts%7Cinfo&meta=&pageids=4335&exintro=1&explaintext=1&exsectionformat=wiki

dijs commented 2 years ago

Thanks. I will take a look soon.

dijs commented 2 years ago

v6.3.0 is out with my initial release of chaining.

https://github.com/dijs/wiki#chain-data-requests-together-for-more-efficient-applications

I am sure there are some use cases I missed, but I wanted to get it out there for people to try out.