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

332
Vistas
Uncaught (in promise) TypeError: s.createConnection is not a function at n.register.c.connect

I'm currently tring to exploit a RSS feed to get latest articles from a website.

What I'm doing is to store these data in a MySQL DB. I do that with Javascript, to take informations from the RSS feed.

When I host the script on my server, it's not working anymore.

For the context of programming, on local, I used XAMPP, with a localhost. Then, I do a parcel build, the script being attached to a HTML page, so that I can call it just by loading the WebPage.

I got the error from the title :
Message of the error : "Uncaught (in promise) TypeError: s.createConnection is not a function at n.register.c.connect

Here is the code :

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

(async () => {

  // Connecting to database

  const mysql = require('mysql');
  const connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: '',
    database: 'dataarticles'
  });
  connection.connect((err) => {
    if (err) throw err;
    console.log('Connected!');
  });

  let feed = await parser.parseURL('http://feedrinse.com/services/rinse/?rinsedurl=235e4f5244e1eeb21ce05fc3d4d68cc0');

  //== Some console.log to check
  // console.log(feed.items[0]['content:encoded']);


  //== Some console.log to check
  // console.log(feed.items[0].title + "\n" 
  //           + feed.items[0].link + "\n"
  //           + feed.items[0].contentSnippet + "\n"
  //           + feed.items[0].pubDate);


  // As the feed doesn't provide the minia of article, I take the first image in the content of the test, by searching it
  let firstPos = feed.items[0]['content:encoded'].search("https://droidsoft.fr/wp-content/uploads/");
  let SecondPos = feed.items[0]['content:encoded'].search('alt="');
  let image = feed.items[0]['content:encoded'].substring(firstPos, SecondPos - 2);
  let pubDate = feed.items[0].pubDate.substring(5, 16);

  //== Some console.log to check
  // console.log(image);
  // console.log(pubDate);

  // We take first item (items[0]) as it's the latest feed. This script is triggered only when there is a new element, so there shouldn't be 
  // any problem of duplication
  connection.query('INSERT INTO `dataarticles` (`Titre`, `URL`, `Description`, `Image`, `date`) VALUES ("' + feed.items[0].title + '", "' + feed.items[0].link + '", "' + feed.items[0].contentSnippet + '", "' + image + '", "' + pubDate + '")', (err, rows) => {
    // if (err) throw err;
    console.log(rows);
  });
})();
about 4 years ago · Santiago Gelvez
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