Skip to content

Instantly share code, notes, and snippets.

@NicolaiSchmid
Created November 27, 2017 16:09
Show Gist options
  • Save NicolaiSchmid/b6f5042c33f86ec79c3acf1d498b8765 to your computer and use it in GitHub Desktop.
Save NicolaiSchmid/b6f5042c33f86ec79c3acf1d498b8765 to your computer and use it in GitHub Desktop.
let count = 0;
fetch('https://api.github.com/repos/google/webfundamentals/commits').then(async(response)=> {
const reader = response.body.getReader();
const textDecoder = new TextDecoder();
while (true) {
count++;
const {value, done} = await reader.read();
const text = textDecoder.decode(value);
console.log(text);
document.getElementById('content').innerHTML += text;
console.log('c', count);
if (done) return;
await sleep();
}
});
async function sleep() {
return new Promise((resolve, reject) => {
setTimeout(() => {
return resolve();
}, 10000);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment