Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function getResponseSize(url) {
- const response = await fetch(url);
- const reader = response.body.getReader();
- let total = 0;
- while (true) {
- const {done, value} = await reader.read();
- if (done) return total;
- total += value.length;
- }
- }
- async function getResponseSize(url) {
- const response = await fetch(url);
- let total = 0;
- for await (const chunk of response.body) {
- total += chunk.length;
- }
- return total;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement