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

164
Views
Problemas al intentar verificar un par de fuentes RSS (desde un archivo de configuración JSON) en Node.JS (usando rss-parser)

Actualmente estoy tratando de hacer un script node.js para leer un par de fuentes RSS de un archivo JSON ( config.json ), verificar a todos y enviar nuevos elementos a su webhook específico para Discord.

El archivo de configuración es el siguiente:

 [ { "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/..." } ]

Y el código que intenté hacer, siguiendo los ejemplos de sincronización del paquete rss-parser npm , es el siguiente:

 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); }); }); });

Pero al intentar ejecutarlo arroja el siguiente 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)

¿Qué estoy haciendo mal en este código? Tenga en cuenta que todavía no escribí la parte de envío del webhook, todavía estoy enfocado en obtener los feeds primero.

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

0

Sospecho que este error específico se debió a que estaba (sin saberlo) usando Node.JS v10 (esa es la versión que apt envía de forma predeterminada para Ubuntu de WSL).

Reinstalar Node.JS usando el repositorio de NodeSource me da la versión 16 que puede ejecutar el código sin problemas.

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!