throw cust error only when failing to parse json
This commit is contained in:
parent
8887996718
commit
ea1691609b
1 changed files with 4 additions and 3 deletions
|
@ -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) => {
|
||||||
|
|
Loading…
Reference in a new issue