diff options
| author | Adam Soltys <[email protected]> | 2023-12-01 20:04:13 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-12-01 20:04:13 -0800 |
| commit | 216a600224fde22ce76b367557a02094ec693886 (patch) | |
| tree | d1189bbaa39db204633523132a7d4767b952717d /src/lib/upload.js | |
| parent | 7d9bc1f54dfd04172e8d6d43ebc2efd6f407e833 (diff) | |
| download | coinos-ui-216a600224fde22ce76b367557a02094ec693886.tar.gz coinos-ui-216a600224fde22ce76b367557a02094ec693886.zip | |
prettier
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); + }); }; |
