diff --git a/src/lib/api.ts b/src/lib/api.ts index e64e3951..6f0d5a55 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -37,7 +37,7 @@ async function send({ const res = await fetch(`${base}/${path}`, opts) if (res.ok || res.status === 422) { const text = await res.text() - if (path === 'wsinit/wsid') return text + if (path === 'wsinit/wsid'|| path.includes('wsinit/channelid')) return text return text ? JSON.parse(text) : {} } diff --git a/src/routes/channel/[channelId]/+page.svelte b/src/routes/channel/[channelId]/+page.svelte index 2fd78059..0065a51f 100644 --- a/src/routes/channel/[channelId]/+page.svelte +++ b/src/routes/channel/[channelId]/+page.svelte @@ -13,7 +13,7 @@ let showDrawer = false onMount(async () => { - const channelSocketId = get(`wsinit/wsid`) + const channelSocketId = await get(`wsinit/channelid?channelId=${data.post._id}`) const channelSocket = new WebSocket( `${env.PUBLIC_WEBSOCKET_URL}/wsinit/channelid/${channelSocketId}/connect` )