dopecodez / Wikipedia

Wikipedia for node and the browser
MIT License
82 stars 19 forks source link

Other languages not fully working #9

Closed wahlstedt closed 3 years ago

wahlstedt commented 3 years ago

Getting results in other languages has problems. Grabbing a page works, but things like summaries and On This Day are not. It seems like it's not using the correct REST url. For example, for the Swedish site the summary page should be sv.wikipedia.org/api/rest_v1/page/summary/Stockholm but it tries to use sv.wikipedia.org/v1/page/page/summary/Stockholm instead.

const wiki = require('wikipedia');

(async () => {
    try {
        const changedLang = await wiki.setLang('sv');
        const page = await wiki.page('Stockholm'); // Works
        const summary = await wiki.summary('Stockholm'); // Fails
        console.log(page, summary);
    } catch (error) {
        console.log(error);
    }
})();
dopecodez commented 3 years ago

Ah, you're right. I actually implemented the REST endpoints later after the language feature was already stable.

The issue looks like it is in this line where I actually set an extra un-needed \page when setting the new object in case language changes.

Very simple fix to just remove that part. A PR would be welcome or I will fix this by tomorrow.