Minor changes

This commit is contained in:
Eduard Urbach 2018-04-16 21:41:37 +02:00
parent bb15daae6b
commit b5a3ec2f86

View File

@ -1,10 +1,10 @@
export function fetchWithProgress(url, opts: RequestInit, onProgress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null): Promise<string> {
export function fetchWithProgress(url, options: RequestInit, onProgress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null): Promise<string> {
return new Promise((resolve, reject) => {
let xhr = new XMLHttpRequest()
xhr.open(opts.method || "GET", url)
xhr.open(options.method || "GET", url)
for(let k in opts.headers || {}) {
xhr.setRequestHeader(k, opts.headers[k])
for(let k in options.headers || {}) {
xhr.setRequestHeader(k, options.headers[k])
}
xhr.onload = e => resolve(xhr.responseText)
@ -14,6 +14,6 @@ export function fetchWithProgress(url, opts: RequestInit, onProgress: ((this: XM
xhr.upload.onprogress = onProgress
}
xhr.send(opts.body)
xhr.send(options.body)
})
}