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

145
Vistas
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 Respuestas
Responde la pregunta

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 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