INNER CODE UNIT · JavaScript
getItemFromWeb
mozilla/firefox-translations · extension/controller/backgroundScript.js:850
const getItemFromWeb = async (tabId, itemURL, fileSize, fileChecksum) => {
let fetchResponse = null;
try {
fetchResponse = await fetch(itemURL);
} catch (error) {
console.log(`Error downloading ${itemURL} (error: ${error})`);
// inform mediator
sendUpdateProgress(tabId, ["updateProgress", "notfoundErrorsDownloadingEngine"]);
return null;
}
if (!fetchResponse.ok) {
console.log(`Error downloading ${itemURL} (response status:${fetchResponse.status})`);
sendUpdateProgress(tabId, ["updateProgress", "notfoundErrorsDownloadingEngine"]);
return null;
}
// function to download using stream of body contents with a timeout