Akioru
Akioru

Reputation: 1

Javascript: Repeat an action each X minute (zapier)

I'm starting to learn Javascript and I would like to use it with Zapier to do a Discord webhook. I want it to send a message in my server every X minute. So what should I write here? I think it's something with SetInterval but I don't know how to use it :(

Thanks!

Upvotes: 0

Views: 214

Answers (2)

Christopher Falone
Christopher Falone

Reputation: 101

You are on the right track.

var intervalMinutes = 5;// fill in whatever number here
setInterval(function(){ 
    // your calling functions code here!
}, (intervalMinutes * 1000 * 60));

... not supported in Zapier, what about:

var intervalMinutes = 5;// fill in whatever number here
function doThing(){
    // your calling functions code here!
    setTimeout(function(){
        doThing();
    }, (intervalMinutes * 1000 * 60));
}
doThing();// first call

Upvotes: 0

Our_Benefactors
Our_Benefactors

Reputation: 3539

var interval = 60000; //one minute in miliseconds

setInterval(function(){

/*code to execute once a minute*/

}, interval);

That's it!

Upvotes: 1

Related Questions