From 004f7149240733f9200b82d7952cf37ac145bd3c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 30 Apr 2020 18:10:27 -0400 Subject: [PATCH] Use response.ok --- src/routes/postSkipSegments.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/postSkipSegments.js b/src/routes/postSkipSegments.js index dc74379..2b0114d 100644 --- a/src/routes/postSkipSegments.js +++ b/src/routes/postSkipSegments.js @@ -112,10 +112,10 @@ async function autoModerateSubmission(submission, callback) { return "Sponsor segment is over 80% of the video."; } else { let overlap = false; - http = await fetch("https://ai.neuralblock.app/api/getSponsorSegments?vid=" + submission.videoID); - if (http.status >= 500 && http.status < 600) return false; + let response = await fetch("https://ai.neuralblock.app/api/getSponsorSegments?vid=" + submission.videoID); + if (!response.ok) return false; - nb_predictions = await http.json(); + nb_predictions = await response.json(); for (const nb_seg of nb_predictions.sponsorSegments){ // The submission needs to be a subset of the widened NB prediction // and at least 65% of NB's prediction.