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

145
Views
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 answers
Answer question

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