Created
November 27, 2017 16:09
-
-
Save NicolaiSchmid/b6f5042c33f86ec79c3acf1d498b8765 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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