diff options
| author | Adam Soltys <[email protected]> | 2022-09-07 13:58:00 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-07 13:58:00 -0700 |
| commit | ec5a14d7d61d5f1797fcfba67dd2d8ef0cca2360 (patch) | |
| tree | 0b138f7fce9b7b6f64bdbb8c0a0103d48f9088b5 /src/lib | |
| parent | 7efa00c9a9cf6587e9c24c1c94d3c8969949e360 (diff) | |
| download | coinos-ui-ec5a14d7d61d5f1797fcfba67dd2d8ef0cca2360.tar.gz coinos-ui-ec5a14d7d61d5f1797fcfba67dd2d8ef0cca2360.zip | |
image uploads
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/upload.js | 6 | ||||
| -rw-r--r-- | src/lib/utils.js | 8 |
2 files changed, 4 insertions, 10 deletions
diff --git a/src/lib/upload.js b/src/lib/upload.js index e7a73fee..d43148fb 100644 --- a/src/lib/upload.js +++ b/src/lib/upload.js @@ -1,13 +1,11 @@ import { get } from 'svelte/store'; import { token } from '$lib/store'; -export const upload = async (file, progress) => { - let url = '/api/profile'; +export const upload = async (file, type, progress) => { + let url = `/api/upload/${type}`; let formData = new FormData(); formData.append('file', file); - console.log('uploading', file); - return new Promise((resolve, reject) => { let ajax = new XMLHttpRequest(); ajax.addEventListener('load', () => { diff --git a/src/lib/utils.js b/src/lib/utils.js index ecf93062..0f665ec4 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -20,12 +20,8 @@ export const get = (url, headers = {}) => }); export const post = (url, body, headers) => { - headers = { ...headers, 'content-type': 'application/json' }; - return fetch(base + url, { - method: 'POST', - body: JSON.stringify(body), - headers - }) + headers = { ...headers, 'content-type': 'application/json', accept: 'application/json' }; + return fetch(base + url, { method: 'POST', body: JSON.stringify(body), headers }) .then((r) => r.text()) .then((body) => { try { |
