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

166
Vistas
javascript cannot convert undefined or null to object question

I am trying javascript for the first time and I am having this trouble with the example:

https://www.twilio.com/blog/web-scraping-and-parsing-html-with-node-js-and-cheerio

It is a web scrapper example that uses got and cheerio, both of which I have installed. But when i run the sample code it gives me 'cannot convert undefined or null to object error.

Why is that? I didn't change anything from the example at all.

the code in question:

  const $ = cheerio.load(response.body);

  $('a').each((i, link) => {
    const href = link.attribs.href;
    console.log(href);
  });
}).catch(err => {
  console.log(err);
});```
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

How does your index.js file look like? I did the tutorial and my code is working. Maybe you are miss typed the url?

Here is my index.js

const fs = require("fs");
const cheerio = require("cheerio");
const got = require("got");

const vgmUrl = "https://www.vgmusic.com/music/console/nintendo/nes";

got(vgmUrl)
  .then((response) => {
    const $ = cheerio.load(response.body);
    $("a").each((i, link) => {
      const href = link.attribs.href;
      console.log(href);
    });
  })
  .catch((err) => {
    console.log(err);
  });
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