diff options
Diffstat (limited to 'src/lib/upload.js')
| -rw-r--r-- | src/lib/upload.js | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/lib/upload.js b/src/lib/upload.js index 92f5290f..552e4a7a 100644 --- a/src/lib/upload.js +++ b/src/lib/upload.js @@ -1,19 +1,19 @@ export const upload = async (file, type, progress, token) => { - let url = `/api/upload/${type}`; - let formData = new FormData(); - formData.append('file', file); + let url = `/api/upload/${type}`; + let formData = new FormData(); + formData.append("file", file); - return new Promise((resolve, reject) => { - let ajax = new XMLHttpRequest(); - ajax.addEventListener('load', () => { - if (ajax.readyState === ajax.DONE) { - if (ajax.status === 200) resolve(ajax.response); - else reject(new Error(`Upload failed: ${ajax.response}`)); - } - }); - ajax.upload.addEventListener('progress', progress, false); - ajax.open('POST', url); - // ajax.setRequestHeader('Authorization', `Bearer ${token}`); - ajax.send(formData); - }); + return new Promise((resolve, reject) => { + let ajax = new XMLHttpRequest(); + ajax.addEventListener("load", () => { + if (ajax.readyState === ajax.DONE) { + if (ajax.status === 200) resolve(ajax.response); + else reject(new Error(`Upload failed: ${ajax.response}`)); + } + }); + ajax.upload.addEventListener("progress", progress, false); + ajax.open("POST", url); + // ajax.setRequestHeader('Authorization', `Bearer ${token}`); + ajax.send(formData); + }); }; |
