throw cust error only when failing to parse json

This commit is contained in:
Dan Peterson 2021-12-23 17:32:22 -06:00 committed by Thomas Zarebczan
parent 8887996718
commit ea1691609b

View file

@ -57,13 +57,14 @@ const fetchLiveChannels = async () => {
const fetchLiveChannel = async (channelId: string) => { const fetchLiveChannel = async (channelId: string) => {
const response = await fetch(`${LIVESTREAM_LIVE_API}/${channelId}`); const response = await fetch(`${LIVESTREAM_LIVE_API}/${channelId}`);
let json;
try { try {
const json = await response.json(); json = await response.json();
if (!(json.data && json.data.live)) throw new Error();
return transformLivestreamData([json.data]);
} catch { } catch {
throw new Error('Error handling live API response'); throw new Error('Error handling live API response');
} }
if (!(json.data && json.data.live)) throw new Error();
return transformLivestreamData([json.data]);
}; };
const filterUpcomingLiveStreamClaims = (upcomingClaims) => { const filterUpcomingLiveStreamClaims = (upcomingClaims) => {