From 4d4324f495695545684e8fe14a286c0c275ce582 Mon Sep 17 00:00:00 2001 From: Gagan Suie Date: Fri, 2 Jun 2023 14:14:49 -0500 Subject: [PATCH] Fix: massage data --- src/routes/browse/+page.svelte | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/routes/browse/+page.svelte b/src/routes/browse/+page.svelte index a9395aa9..3d6c55c3 100644 --- a/src/routes/browse/+page.svelte +++ b/src/routes/browse/+page.svelte @@ -6,9 +6,31 @@ import SectionTable from '$lib/components/Browse/Sections/SectionTable.svelte' import type { PageData } from './$types' import { page } from '$app/stores' + import { onMount } from 'svelte' + import { get, patch } from '$lib/api' + import { getSectionUrl } from '$lib/utils' export let data: PageData $: user = $page.data.user + + onMount(async () => { + const allChannels = await get(getSectionUrl({ sectionId: '', query: '', skip: 0, limit: 500 })) + console.log('got here----', allChannels) + allChannels.forEach(async (element: any) => { + let created = '' + if (element?.createdOn) { + created = element?.createdOn + } else { + created = element?.createdAt + } + console.log('got here----createdAt', created) + element.createdAt = created + await patch(`channels`, element, { + userId: $page.data.user?.userId, + token: $page.data.user?.token + }) + }) + })