请求失败等3s后再试
This commit is contained in:
parent
f3e47b16d0
commit
e8e5f68c5b
@ -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, "请求成功,但服务器处理失败,保存失败信息。");
|
||||
|
@ -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, "请求成功,但服务器处理失败,保存失败信息。");
|
||||
|
@ -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, "请求成功,但服务器处理失败,保存失败信息。");
|
||||
|
@ -14,7 +14,7 @@ async function getApiResult(url) {
|
||||
} else {
|
||||
// 请求失败
|
||||
console.log(`error is ${error}`);
|
||||
resolve("error");
|
||||
resolve(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user