setTimeout(async function() {
console.log('returning from server', new Date().toLocaleTimeString());
}, 4000);
}
setInterval(async function(){
let insideSetInterval = new Date().toLocaleTimeString();
console.log('insideSetInterval', insideSetInterval);
await fakeCallToServer();
}, 2000);
Results :
insideSetInterval 10:57:25 AM
insideSetInterval 10:57:27 AM
insideSetInterval 10:57:29 AM
returning from server 10:57:30 AM
returning from server 10:57:31 AM
Question: How can i make API request every 2 seconds?
SetInterval didn't work?
Обсуждают сегодня