Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda