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

147
Vistas
How to disable multiple axios.post?
function executeStatement() {
    let time = global.setInterval(() => {
        var date = new Date();
        if (date.getHours() === 14 && date.getMinutes() === 38) {
            console.log("What did it choose?", result_shuffle);
            console.log("Time", time);
                if (shufflearray) {
                    var sql = `UPDATE developers SET selected = ${result_shuffle.selected} + 1 WHERE id = ${result_shuffle.id}`;
                    db.query(sql, function (err, result) {
                        if (err) throw err;
                        console.log(result.affectedRows + " record(s) updated");
                    });
                    axios.post('https://hooks.slack.com/services/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', {
                        blocks: [
                            {
                                type: 'section',
                                text: {
                                    type: 'mrkdwn',
                                    text: `Name: yo \n\n Email: sup`,
                                },
                            },
                        ],
                    })   
                }
                else {
                    const abort = "abort"
                    console.log(abort);
                }
            }
        }, 2000);
};

So I'm building a function that executes a certain value when the timestamp 14:38 has hit. This message is then redirected to a Slack channel (Slack bot basically). Everything works smoothly BUT I'm having a problem. The axios.post is sending multiple POSTS.

So my slack channel is now being spammed with Name: Email: posts.

How can I make it so it only publishes once when the time hits? Or how can I make the time more precise so the axios.post will stop?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can modify your if statement something like this

if (date.getHours() === 14 && date.getMinutes() === 38 && date.getSeconds() < 2) {
// ....
}

This will check for seconds as well

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