dijs / wiki

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

Error: Something went wrong. Could not fill variables in: (undefined) undefined #64

Closed kper closed 6 years ago

kper commented 6 years ago

Code:

var test = 3165;

wiki()
    .findById(test)
    .then(page => {
        console.log(page);
        page.mainImage().then((img) => {
            console.log(img);
        });
    });

Output:

{ raw: 
   { pageid: 3165,
     ns: 0,
     title: 'ACF Fiorentina',
     contentmodel: 'wikitext',
     pagelanguage: 'en',
     pagelanguagehtmlcode: 'en',
     pagelanguagedir: 'ltr',
     touched: '2017-10-17T20:18:19Z',
     lastrevid: 805814864,
     length: 63727,
     fullurl: 'https://en.wikipedia.org/wiki/ACF_Fiorentina',
     editurl: 'https://en.wikipedia.org/w/index.php?title=ACF_Fiorentina&action=edit',
     canonicalurl: 'https://en.wikipedia.org/wiki/ACF_Fiorentina' },
  html: [Function: html],
  content: [Function: content],
  summary: [Function: summary],
  images: [Function: images],
  references: [Function: references],
  links: [Function: links],
  categories: [Function: categories],
  coordinates: [Function: coordinates],
  info: [Function: q],
  backlinks: [Function: backlinks],
  rawImages: [Function: h],
  mainImage: [Function: mainImage],
  langlinks: [Function: langlinks],
  rawInfo: [Function: p] }
(node:7578) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Something went wrong. Could not fill variables in: (undefined) undefined
dijs commented 6 years ago

Fixed in v4.3.4

The issue was in the info box parser. The parser was failing on one field, and giving up. Instead I now return undefined for the problem field and return whatever else we can parse.

Should fix many issues I think.