Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
75160b7dbc | |||
af887a0bfb |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.14.3",
|
||||
"version": "0.14.5",
|
||||
"description": "Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
|
@ -43,12 +43,12 @@ export function uploadWithProgress<T>(options: {
|
||||
options.files.forEach(f => formData.append('file', f));
|
||||
|
||||
xhr.withCredentials = !!options.withCredentials
|
||||
Object.entries(options.headers || {}).forEach(([key, value]) => xhr.setRequestHeader(key, value));
|
||||
xhr.upload.addEventListener('progress', (event) => event.lengthComputable ? prog(event.loaded / event.total) : null);
|
||||
xhr.upload.addEventListener('load', (resp) => res(<any>resp));
|
||||
xhr.upload.addEventListener('error', (err) => rej(err));
|
||||
|
||||
xhr.open('POST', options.url);
|
||||
Object.entries(options.headers || {}).forEach(([key, value]) => xhr.setRequestHeader(key, value));
|
||||
xhr.send(formData);
|
||||
});
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ export class Http {
|
||||
});
|
||||
|
||||
if(typeof opts.body == 'object' && opts.body != null && headers['Content-Type'] == 'application/json')
|
||||
opts.body = JSON.stringify(opts.json);
|
||||
opts.body = JSON.stringify(opts.body);
|
||||
|
||||
// Send request
|
||||
return new PromiseProgress((res, rej, prog) => {
|
||||
|
Reference in New Issue
Block a user