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

156
Views
Getting null response from cheerio block

I am trying to get descriptions array data in another array of Hello function but I get an error, "Cannot read property length of undefined", while I already consoled the description array and it is giving me the needed data. Then what might be the reason for this error .

const unirest = require("unirest");
const cheerio = require("cheerio");

const data = async () => {
  var description = [];
  unirest
    .get("https://www.google.com/search?q=rotating proxies")
    .headers({ Accept: "application/json", "Content-Type": "application/json" })
    .proxy(
      "proxy"
    )//hided
    .then((response) => {
      const $ = cheerio.load(response.body);

      $(".uEierd").each((i, el) => {
        description[i] = $(el).find(".yDYNvb").text();
        console.log(description[i]);
        return description;
      });
    });
};
async function Hello() {
  var result2 = [];
  result2 = await data();
  for (let i = 0; i < result2.length; i++) {
    console.log(result2[i]);
  }
}
Hello();
about 4 years ago · Juan Pablo Isaza
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!