Improved uploader

This commit is contained in:
Eduard Urbach 2018-04-17 13:07:42 +02:00
parent d9ff1513b8
commit 0f28cdbc3d

View File

@ -10,9 +10,13 @@ export function fetchWithProgress(url, options: RequestInit, onProgress: ((this:
xhr.onload = e => resolve(xhr.responseText)
xhr.onerror = reject
if(xhr.upload && onProgress) {
if(onProgress) {
xhr.addEventListener("progress", onProgress)
if(xhr.upload) {
xhr.upload.onprogress = onProgress
}
}
xhr.send(options.body)
})