Wikipedia icon indicating copy to clipboard operation
Wikipedia copied to clipboard

Error using page() to get infobox()

Open kingram6865 opened this issue 2 years ago • 3 comments

Do you have any thoughts on what Invalid attempt to destructure non-iterable instance is referring to in this context?

/PROJECTS/research/node_modules/wikipedia/dist/page.js:256
                throw new errors_1.infoboxError(error);
                      ^

infoboxError: infoboxError: TypeError: Invalid attempt to destructure non-iterable instance
    at Page.infobox (/PROJECTS/research/node_modules/wikipedia/dist/page.js:256:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: undefined
}

Node.js v18.16.0

The code:

const wiki = require('wikipedia')
let page, infobox
async function getPage(input) {
  try {
    page = await wiki.page(input)
    infobox = await page.infobox()
    console.log(infobox)
  } catch (error) {
    console.log(error)
  }
  return infobox
}

getPage('John M. Vining')

kingram6865 avatar Jul 03 '23 22:07 kingram6865

Can you mention which page you faced this issue in? I think it might be a problem with https://www.npmjs.com/package/infobox-parser but we would need the page name to confirm @kingram6865

dopecodez avatar Jul 10 '23 16:07 dopecodez

This is the page that I was attempting to parse: https://en.wikipedia.org/wiki/John_Vining

kingram6865 avatar Jul 11 '23 02:07 kingram6865

I think it's possible you need to account for the case where there is no Infobox.

Also I think the page that is use case for my error example may have been corrected since this issue was created.

kingram6865 avatar Jan 27 '24 09:01 kingram6865

You close this issue? It's not fixed. You asked me about a page when all you have to do is run the example code I put in my comment to see the results. I told you what the likely problem is.

kingram6865 avatar May 20 '24 04:05 kingram6865