diff --git a/src/get_bilibili_hotband.js b/src/get_bilibili_hotband.js index 2a38c57..7da0f90 100644 --- a/src/get_bilibili_hotband.js +++ b/src/get_bilibili_hotband.js @@ -19,7 +19,10 @@ async function main() { let result = await requestUtils.getApiResult(API_URL); if (result.code != 0) { - console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,正在重试。"); + console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,等待3s后重试。"); + await new Promise((resolve) => { + setTimeout(resolve, 3000); // 等待3秒 + }); result = await requestUtils.getApiResult(API_URL); if (result.ok != 1) { console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,保存失败信息。"); diff --git a/src/get_bilibili_rank.js b/src/get_bilibili_rank.js index dec154b..01be364 100644 --- a/src/get_bilibili_rank.js +++ b/src/get_bilibili_rank.js @@ -19,7 +19,10 @@ async function main() { let result = await requestUtils.getApiResult(API_URL); if (result.code != 0) { - console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,正在重试。"); + console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,等待3s后重试。"); + await new Promise((resolve) => { + setTimeout(resolve, 3000); // 等待3秒 + }); result = await requestUtils.getApiResult(API_URL); if (result.ok != 1) { console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,保存失败信息。"); diff --git a/src/get_weibo_hotband.js b/src/get_weibo_hotband.js index cb08c35..bbe9d5a 100644 --- a/src/get_weibo_hotband.js +++ b/src/get_weibo_hotband.js @@ -19,7 +19,10 @@ async function main() { let result = await requestUtils.getApiResult(API_URL); if (result.ok != 1) { - console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,正在重试。"); + console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,等待3s后重试。"); + await new Promise((resolve) => { + setTimeout(resolve, 3000); // 等待3秒 + }); result = await requestUtils.getApiResult(API_URL); if (result.ok != 1) { console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,保存失败信息。"); diff --git a/src/utils/requestUtils.js b/src/utils/requestUtils.js index ef37af4..6eab7d1 100644 --- a/src/utils/requestUtils.js +++ b/src/utils/requestUtils.js @@ -14,7 +14,7 @@ async function getApiResult(url) { } else { // 请求失败 console.log(`error is ${error}`); - resolve("error"); + resolve(null); } }); });