From d29392e33ae7e26b7e310c5a06c677662a6c0dea Mon Sep 17 00:00:00 2001 From: Roland Date: Fri, 17 Feb 2023 17:02:38 -0700 Subject: [PATCH] Channel download may not return json. --- app/src/api.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/src/api.js b/app/src/api.js index 5481b7a0..b07cb97e 100644 --- a/app/src/api.js +++ b/app/src/api.js @@ -223,14 +223,16 @@ export async function getVideosStatistics() { export async function downloadChannel(channelId) { let url = `${VIDEOS_API}/channels/download/${channelId}`; let response = await apiPost(url); - let json = await response.json(); - if (response.status === 400 && json['code'] === 30) { - toast({ - type: 'error', - title: 'Cannot Download!', - description: 'This channel does not have a download record. Modify the frequency.', - time: 5000, - }); + if (response.status === 400) { + const json = await response.json(); + if (json['code'] === 30) { + toast({ + type: 'error', + title: 'Cannot Download!', + description: 'This channel does not have a download record. Modify the frequency.', + time: 5000, + }); + } } } @@ -659,10 +661,7 @@ export async function getStatistics() { return contents; } else { toast({ - type: 'error', - title: 'Error!', - description: 'Unable to get file statistics', - time: 5000, + type: 'error', title: 'Error!', description: 'Unable to get file statistics', time: 5000, }) } }