Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda