Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
Issues trying to check a couple of RSS feeds (from a JSON config file) in Node.JS (using rss-parser)

I'm currently trying to make a node.js script to read a couple of RSS feeds from a JSON file (config.json), check everyone and send new items to it's specific webhook for Discord.

The config file is the following:

[
  {
    "name": "r/aww",
    "avatar": "https://example.com/avatar.jpg",
    "rss_url": "https://www.reddit.com/r/aww/top/.rss",
    "webhook_url": "https://discord.com/api/webhooks/..."
  },
  {
    "name": "r/ImaginaryLandscapes",
    "avatar": "https://example.com/avatar.jpg",
    "rss_url": "https://www.reddit.com/r/ImaginaryLandscapes/top/.rss",
    "webhook_url": "https://discord.com/api/webhooks/..."
  }
]

And the code that i attempted to do, following sync examples from rss-parser npm package, is the following:

let Parser = require('rss-parser');

let parser = new Parser();

const config = require("./config.json");

config.forEach(element => {
    
    parser.parseURL(element.rss_url, function(err, feed) {
      console.log(feed);

      feed.items.forEach(function(entry) {
        console.log(entry.title + ':' + entry.link);
      });
    });

});

But trying to run it throws the following error:

undefined
/mnt/d/misc/feedchecker/script.js:28
          feed.items.forEach(function(entry) {
               ^

TypeError: Cannot read property 'items' of undefined
    at /mnt/d/misc/feedchecker/script.js:28:9
    at Timeout.setTimeout [as _onTimeout] (/mnt/d/misc/feedchecker/node_modules/rss-parser/lib/utils.js:63:29)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)

What I'm doing wrong on this code? Please note that i still didn't wrote the webhook sending part, I'm focused still on fetching the feeds first.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I suspect this specific error was caused because i was (without knowing) using Node.JS v10 (that is the version that is shipped by apt by default for WSL's Ubuntu).

Reinstalling Node.JS using NodeSource repository gives me the version 16 that is able to run the code without issues.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!