From ff5a0fa87aa8544f10b4e173c6dd2b24ed410bb4 Mon Sep 17 00:00:00 2001 From: Qizot Date: Sat, 21 Mar 2020 19:25:10 +0100 Subject: [PATCH] Fixed an error where invalid request would corrupt database --- .../src/services/timeline_refresher.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/coronavirus-visualizer-api/src/services/timeline_refresher.ts b/backend/coronavirus-visualizer-api/src/services/timeline_refresher.ts index 4f53455..1e6d2d8 100644 --- a/backend/coronavirus-visualizer-api/src/services/timeline_refresher.ts +++ b/backend/coronavirus-visualizer-api/src/services/timeline_refresher.ts @@ -16,6 +16,10 @@ export const refreshTimelinesJob = async () => { try { const response = await fetch(url); const body = await response.json(); + if (response.status != 200) { + console.log(body); + continue; + } const timeline = await VirusTimelineSchema.findOne({code: countries[key]}); if (timeline) {