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

204
Vistas
How do I go back to the beginning of the function in asynchronous structure?

I don't know if the problem is asynchronous but my code didn't work here How do I get it to recheck every second on the else side if the if function in dat().then is false? Currently my dat() function in settimeout is not working. I didn't expect it to work anyway

var dat = async () => {
        await document.querySelector("body").click();
}

dat().then(() => {
    if(document.querySelector("body").className.indexOf("position") == -1){
       console.log("right");
    }
    else setTimeout(arguments.callee, 1000);

})
dat();
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here's my attempt to write your code with the looping the stated desired loop.

var dat = async () => {
    await document.querySelector("body").click();
}

const unclicked = () => (
    document.querySelector("body").className.indexOf("position") == -1);

do {
    await dat();
    if (unclicked())
        console.log("right");
    else
        setTimeout(arguments.callee, 1000);
} while (true) 

However, I admit I agree with Kevin B's comment in that setTimeout and `document.querySelector(...).click() don't return Promises.

If you care to comment, I will gladly update the answer to reflect the question.

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