Skip to content

Instantly share code, notes, and snippets.

View techhahn's full-sized avatar

Pritesh Panjiker techhahn

View GitHub Profile
@techhahn
techhahn / example.txt
Created February 7, 2018 19:15
Any way to print proper values without moving setTimeout outside the loop?
//HTML
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
//JS
var list = document.querySelectorAll('li');
var listArr = Array.prototype.slice.call(list);
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) {