From 45cb904d65d6cc824a49a067b3baa4e5ce579c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Fri, 5 Aug 2022 22:42:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20Cannot=20read=20properties?= =?UTF-8?q?=20of=20null=20(reading=20'hotgov')=20=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/get_weibo_hotband.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/get_weibo_hotband.js b/src/get_weibo_hotband.js index af69e84..43a1ef0 100644 --- a/src/get_weibo_hotband.js +++ b/src/get_weibo_hotband.js @@ -26,7 +26,7 @@ async function main() { result = await requestUtils.getApiResult(API_URL); if (result.ok != 1) { console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,保存失败信息。"); - // ok 不为 1,那么久直接保存便于后续分析,不进行后续处理 + // ok 不为 1,那么就直接保存便于后续分析,不进行后续处理 fileUtils.saveJSON({ saveFolder: DATA_FOLDER, now: now, @@ -56,6 +56,17 @@ async function main() { let data = JSON.parse(JSON.stringify(result.data)); + if (!data) { + fileUtils.saveJSON({ + saveFolder: DATA_FOLDER, + now: now, + fileNameSuffix: `origin--parse-error`, + object: result, + compress: true, + uncompress: false + }); + return; + } /** * 过滤掉不需要的数据