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

177
Views
Return object from array map inside a for loop JS

I'm trying to return an object from an array map inside a for loop and push it to productsData array but I'm getting [ [Object], [Object] ]. The array in question is 'lol'. Here's the code below:

for (let i = 0; i < productsUrls.length; i++) {
        let ficheTechnique = [];
        let request = await axios.get(productsUrls[i]);
        const $ = cheerio.load(request.data);
        let productUrl = productsUrls[i];
        let title = $('div.col10').find('h1.-fs20.-pts.-pbxs').text();
        let price = $('div.-phs').find('div span.-b.-ltr.-tal.-fs24').text();
        let description = $('div.card.aim.-mtm').find('div.markup.-mhm.-pvl.-oxa.-sc').text();
        let descriptionImg = $('div.card.aim.-mtm').find('div.markup.-mhm.-pvl.-oxa.-sc center img').attr('data-src');
        let lol = $('.row.-pas article').map((i, el) => {
            let h2 = $(el).find('h2.hdr.-upp.-fs14.-m.-pam').text();
            let characteristiques = $(el).find('.markup.-pam').text() || $(el).find('.-pvs.-mvxs.-phm.-lsn').text();
            return {
                h2,
                characteristiques
            };
        }).get();
        console.log('ficheTechnique', lol);
        productsData.push({
            productUrl,
            title,
            // price,
            // description,
            // descriptionImg,
            // ficheTechnique,
            lol
        })
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your map call is returning an array of objects, each containing h2 and characteristiques attributes.

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!