Skip to content

Instantly share code, notes, and snippets.

@jakearchibald
Last active June 15, 2021 15:54
Show Gist options
  • Save jakearchibald/0b37865637daf884943cf88c2cba1376 to your computer and use it in GitHub Desktop.
Save jakearchibald/0b37865637daf884943cf88c2cba1376 to your computer and use it in GitHub Desktop.
async function getResponseSize(url) {
const response = await fetch(url);
let total = 0;
// Here comes the new bit…
for await (const value of response) {
total += value.length;
console.log('Received chunk', value);
}
return total;
}
@dandv
Copy link

dandv commented Oct 11, 2018

I get TypeError: response is not async iterable.

@Coder2012
Copy link

Coder2012 commented Jan 29, 2019

@dandv

response is a Promise and is not iterable, an array of them would be iterable however.

@SAIDEEPAKALETI
Copy link

I get TypeError: response is not async iterable.

i get the same error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment