Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when getting fields from a sitemap that includes items without the field #154

Closed
rchiba opened this issue Nov 8, 2024 · 0 comments

Comments

@rchiba
Copy link
Contributor

rchiba commented Nov 8, 2024

Note: I submitted a PR to resolve this issue here: #155

I ran into this issue when trying to get the fields of each page from sitemaps that include indexes.

Steps to reproduce:

const Sitemapper = require('sitemapper');
const url = 'https://wp.seantburke.com/sitemap.xml';
let sitemapper = new Sitemapper({
    fields: { "loc": true,
        "lastmod": true,
        "priority": true,
        "changefreq": true
    }
});
sitemapper.fetch(url)
    .then(data => {
        console.log(data);
    })

Expected

A successful response which includes each item of the sitemap and the related fields.

Actual

TypeError: Cannot read properties of undefined (reading 'sites')
    at /Users/ryochiba/Desktop/work/tmp/foobar/node_modules/sitemapper/lib/assets/sitemapper.js:1:1484
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/ryochiba/Desktop/work/tmp/foobar/node_modules/sitemapper/lib/assets/sitemapper.js:1:443)
    at g (/Users/ryochiba/Desktop/work/tmp/foobar/node_modules/sitemapper/lib/assets/sitemapper.js:1:642)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants