I have a Promise based function which i want to call at fixed interval, Lets say at every 60 seconds. But i also want to make sure that function is called only if the previously called function is executed completely and i want to continue this for infinite time
function fun(){
return new Promise((resolve,reject)=>{
//Some database queries which may or may not complete in 60 seconds
resolve("done")
})
}
setInterval(()=>{
fun().then(d=>{
console.log(d)
})
},60000)
Above code will not check for previously called function is completed or not. but i want to make sure that