Fetch API & Handling JSON Responses
What functionality does this code provide?
async function fetchWithProgress(url, onProgress) {
const response = await fetch(url);
const reader = response.body.getReader();
const contentLength = +response.headers.get('Content-Length');
let receivedLength = 0;
while(true) {
const {done, value} = await reader.read();
if (done) break;
receivedLength += value.length;
onProgress(receivedLength / contentLength);
}
}