dijs / wiki

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

page.mainImage() throws error 'Cannot read property 'imageinfo' of undefined' #54

Closed kper closed 6 years ago

kper commented 6 years ago

I found another one with FC Santa Coloma

Code:

wiki().page("FC Santa Coloma").then(function(page) {
    page.mainImage().then(console.log);
  })

Similiar error like #53

(node:7864) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'imageinfo' of undefined
(node:7864) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

There is again a mismatch between title and mainImageName:

File:Santa-Coloma1.png == Image:Santa-Coloma1.png
File:Question book-new.svg == Image:Santa-Coloma1.png
File:Flag of France.svg == Image:Santa-Coloma1.png
File:Flag of Spain.svg == Image:Santa-Coloma1.png
...

Modified Code:

const image = images.find(({ title }) => {console.log(title + " == " + mainImageName);title.indexOf(mainImageName) !== -1});
dijs commented 6 years ago

Thanks for the find. This has been fixed in v4.0.1

hzitoun commented 6 years ago

Still having the same problem :

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