aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/upload.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-12-06 20:33:45 -0800
committerAdam Soltys <[email protected]>2023-12-06 20:33:45 -0800
commit6b3ff247e4125941a611369ed9bb74a2ffca57d8 (patch)
tree91da939350398188834e5e002bc78011a2a8e5bf /src/lib/upload.js
parentbb59ac3e4e7fcbf7f8a48820eab0ee21558183fc (diff)
parentd69c34cf389639eac82d24d1f1b02f038ef42399 (diff)
downloadcoinos-ui-6b3ff247e4125941a611369ed9bb74a2ffca57d8.tar.gz
coinos-ui-6b3ff247e4125941a611369ed9bb74a2ffca57d8.zip
Merge branch 'master' into swapee
Diffstat (limited to 'src/lib/upload.js')
-rw-r--r--src/lib/upload.js33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/lib/upload.js b/src/lib/upload.js
index d8b27061..552e4a7a 100644
--- a/src/lib/upload.js
+++ b/src/lib/upload.js
@@ -1,20 +1,19 @@
export const upload = async (file, type, progress, token) => {
- console.log('TYPE', type);
- 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);
+ });
};