diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/socket.js | 1 | ||||
| -rw-r--r-- | src/lib/upload.js | 5 | ||||
| -rw-r--r-- | src/lib/utils.js | 14 |
3 files changed, 2 insertions, 18 deletions
diff --git a/src/lib/socket.js b/src/lib/socket.js index dac2935e..6317595b 100644 --- a/src/lib/socket.js +++ b/src/lib/socket.js @@ -37,6 +37,7 @@ const maxReconnectDelay = 16000; let currentReconnectDelay = initialReconnectDelay; export function connect(t) { + console.log('CONNECT'); token = t; clearInterval(interval); diff --git a/src/lib/upload.js b/src/lib/upload.js index d43148fb..4b03059c 100644 --- a/src/lib/upload.js +++ b/src/lib/upload.js @@ -1,7 +1,4 @@ -import { get } from 'svelte/store'; -import { token } from '$lib/store'; - -export const upload = async (file, type, progress) => { +export const upload = async (file, type, progress, token) => { let url = `/api/upload/${type}`; let formData = new FormData(); formData.append('file', file); diff --git a/src/lib/utils.js b/src/lib/utils.js index a4c77d58..7a988469 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -38,17 +38,6 @@ export const post = (url, body, headers) => { }); }; -export const put = (url, body, headers) => { - headers = { ...headers, 'content-type': 'application/json' }; - return fetch(base + url, { - method: 'PUT', - body: JSON.stringify(body), - headers - }).then(async (r) => { - if (!r.ok) throw new Error('put failed'); - }); -}; - export const copy = (text) => { navigator.clipboard.writeText(text); success('Copied!'); @@ -109,14 +98,11 @@ export const info = (m) => { export const login = async (user, cookies) => { let maxAge = 30 * 24 * 60 * 60; let { token } = await post('/login', user); - console.log('logged in', token); let expires = new Date(); expires.setSeconds(expires.getSeconds() + maxAge); - console.log('cs'); cookies.set('token', token, { path: '/' }); - console.log('bs'); }; export const auth = (cookies) => ({ authorization: `Bearer ${cookies.get('token')}` }); |
