diff --git a/ts/category.ts b/ts/category.ts index 0061cd5..48b7562 100644 --- a/ts/category.ts +++ b/ts/category.ts @@ -1,4 +1,4 @@ -export class VideoMeta { +class VideoMeta { name: string|null thumbnail: string|null category: string @@ -79,4 +79,16 @@ export class VideoMeta { } } +export async function fetch_category_videos() : Promise> { + const endpoint = window.location.origin + '/api' + window.location.pathname + let videos: Array = [] + const response = await fetch(endpoint) + if(response.headers.get('Content-Type') == 'application/json') { + const raw = JSON.parse(await response.text()) + for(const vid_raw of raw) { + videos.push(new VideoMeta(vid_raw)) + } + } + return videos +}