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

139
Views
loading the signin before the home page with nodejs

I want to make a POST to website x which requires a login but the problem is that the page load before siginin(check the console.log) how to fix this please

var request = require("request");

var headers = {
    authority: "",
    origin: url,
    "content-type": "application/x-www-form-urlencoded",
    cookie: "",
};

var dataString = "";

var options = {
    url: loginUrl,
    method: "POST",
    headers: headers,
    body: dataString,
};

function callback(error, response, body) {
    if (!error) {
        console.log("login successfully");
    }
}

async function ok() {
    await request(options, callback);
    let result = await request.get(websiteUrl);
    const page = result.data;
    console.log("page loading");
}
ok();

console.log:

page loading
login successfully
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The request package is deprecated. It does not support promises/async/await. Use a package such as axios, which supports promises, hence supporting async/await.

var axios = require("axios")

...

async function ok() {
    await axios(options, callback);
    let result = await request.get(websiteUrl);
    const page = result.data;
    console.log("page loading");
}

You may have to change the format of options, as per docs, but it should be similar to above.

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!