Skip to content

Instantly share code, notes, and snippets.

@techhahn
Created May 14, 2021 10:49
Show Gist options
  • Save techhahn/9459ff8e06ed9dee6021d53eaad689b5 to your computer and use it in GitHub Desktop.
Save techhahn/9459ff8e06ed9dee6021d53eaad689b5 to your computer and use it in GitHub Desktop.
let timer = setInterval(() => {
if(window.cancelTimer && timer) {
clearInterval(timer);
}
fetch('https://cdn-api.co-vin.in/api/v2/appointment/sessions/calendarByPin?pincode=403508&date=14-05-2021').then(res => res.json()).then(obj => {
//Will have to check for the center and change it here
console.log(obj.centers);
obj.centers[1].sessions.forEach(slot => {
console.log(slot.available_capacity, slot.date);
if(slot.available_capacity) {
window.open("https://www.youtube.com/watch?v=IO9XlQrEt2Y", '_blank ');
}
})
})
}, 60 * 1000);
// Change cancel timer to true manually if need to cancel once slot becomes available
cancelTimer = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment