dijs / wiki

Wikipedia Interface for Node.js
MIT License
313 stars 62 forks source link

(node:2016) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read prop erty 'imageinfo' of undefined #62

Closed hzitoun closed 6 years ago

hzitoun commented 6 years ago

Getting this error when calling mainImage()function. Version used "wikijs": "^4.3.1" Variable initialized as follow: const wiki = require('wikijs').default({ apiUrl: 'http://fr.wikipedia.org/w/api.php' }) (language fr). Example to reproduce the problem :

   wiki.search('royan') .then(data => {
        console.log(data);
        if (data && data.results && data.results.length > 0) {
            wiki.page(data.results[0])
                .then(page => {
                    console.log(page);
                    let pageUrl = page.raw.fullurl;
                    let imageUrl = null;
                    let summary = null;
                    page.mainImage().then(img => {   //here!
                        console.log("img", img);
                        imageUrl = img;
                        page.summary().then(sum => {
                        summary = utils.getFirstSentences(sum, 3);
                });
        } else {
        }
    });
dijs commented 6 years ago

Fixed in v4.3.2

hzitoun commented 6 years ago

Great! Thanks.

dijs commented 6 years ago

No problem