diff options
| author | Adam Soltys <[email protected]> | 2024-10-18 09:08:07 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-10-18 09:09:14 -0700 |
| commit | 002cd9134d2e23bec34f838f6d6fefba41f2d530 (patch) | |
| tree | 92fa0e0ab54ce1a715d25f458de8b8ed8cc70bd5 /src/lib/upload.ts | |
| parent | f6bfe889d91bc6e36b0300d7b618f10158efe176 (diff) | |
| download | coinos-ui-002cd9134d2e23bec34f838f6d6fefba41f2d530.tar.gz coinos-ui-002cd9134d2e23bec34f838f6d6fefba41f2d530.zip | |
biome format
Diffstat (limited to 'src/lib/upload.ts')
| -rw-r--r-- | src/lib/upload.ts | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/lib/upload.ts b/src/lib/upload.ts index 31c235c6..6bc5eaf3 100644 --- a/src/lib/upload.ts +++ b/src/lib/upload.ts @@ -1,18 +1,18 @@ export const upload = async (file, type, progress) => { - 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.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.send(formData); + }); }; |
