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

136
Views
How to execute callback method after request finished?

callback does not execute after request finished. Please give me suggestions. How can I execute the callback method after request is finished successfully. Thanks in advance.

async function sendSearchRequest(config, search_url, message, ambiente, callback){
      const options = {
        'method': 'POST',
        'url': 'https://www.example.com',
        'headers': {
          ...
        },
        form: {...}
      };
      await request(options, function (error, response) {
        if (error) {
          consolel.log("Error!----------------------------", error);
        }
        const $ = cheerio.load(response.body);
        const szPages = $('#divResultadosSuperior').find('table > tbody > tr > td:first-child').text();
        const szTexts = szPages.split(' ');
        const nPages = Math.ceil(szTexts[szTexts.length - 2] / 10);
        console.log("This is Number of Page: -----------", nPages);
        for(let i = 1; i <= nPages; i ++)
        {
          downloadPDFsOfPage(i, response.headers['set-cookie'][0], pdf_lists, search_url, message);
        }
        //await scrapPdf(response.body, response.headers['set-cookie'][0]);
      }).end(callback())
    }
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!