diff --git a/packages/react/src/lib/fetch.ts b/packages/react/src/lib/fetch.ts index fd5fd1718..9e67b0ede 100644 --- a/packages/react/src/lib/fetch.ts +++ b/packages/react/src/lib/fetch.ts @@ -6,8 +6,6 @@ function toStr(x: unknown): string { const stringify = (obj: object) => { return (new URLSearchParams(Object.entries(obj).flatMap(([k, v]) => Array.isArray(v) ? v.map(x => ([k, toStr(x)])) : [[k, typeof v === "object" ? JSON.stringify(v) : String(v)]]))).toString() - - } diff --git a/packages/react/src/services/live.service.ts b/packages/react/src/services/live.service.ts index 49800a0da..efbb34ccc 100644 --- a/packages/react/src/services/live.service.ts +++ b/packages/react/src/services/live.service.ts @@ -8,7 +8,7 @@ interface UseLiveParams { lang?: string[]; type?: VideoType[]; topic?: string; - include?:VideoIncludeParam[]; + include?: VideoIncludeParam[]; org?: string; mentioned_channel_id?: string; sort?: string; @@ -20,6 +20,11 @@ interface UseLiveParams { id?: string; } +function listToString(list: string[] | undefined) { + if (!list) return undefined + return list.join(","); +} + export function useLive( params?: UseLiveParams, config?: UseQueryOptions, @@ -28,7 +33,7 @@ export function useLive( return useQuery( ["live", params], - async () => (await client("/api/v2/live", { params })), + async () => (await client("/api/v2/live", { params: { ...params, type: listToString(params?.type), lang: listToString(params?.lang), include: listToString(params?.include) } })), config, ); }