diff --git a/scripts/Utils/index.ts b/scripts/Utils/index.ts index b7c009a5..ea90587f 100644 --- a/scripts/Utils/index.ts +++ b/scripts/Utils/index.ts @@ -4,5 +4,5 @@ export * from "./findAll" export * from "./plural" export * from "./requestIdleCallback" export * from "./swapElements" -export * from "./fetchWithProgress" +export * from "./uploadWithProgress" export * from "./bytesHumanReadable" \ No newline at end of file diff --git a/scripts/Utils/fetchWithProgress.ts b/scripts/Utils/uploadWithProgress.ts similarity index 82% rename from scripts/Utils/fetchWithProgress.ts rename to scripts/Utils/uploadWithProgress.ts index 017d7e61..45010c2a 100644 --- a/scripts/Utils/fetchWithProgress.ts +++ b/scripts/Utils/uploadWithProgress.ts @@ -2,7 +2,13 @@ export function uploadWithProgress(url, options: RequestInit, onProgress: ((ev: return new Promise((resolve, reject) => { let xhr = new XMLHttpRequest() - xhr.onload = e => resolve(xhr.responseText) + xhr.onload = () => { + if(xhr.status >= 400) { + return reject(xhr.responseText) + } + + resolve(xhr.responseText) + } xhr.onerror = reject if(onProgress && xhr.upload) {