修复获取ip api失败时,无法登陆

修复禁用或者运行定时任务出现重复
This commit is contained in:
hanhh committed 2021-08-23 13:44:54 +08:00
1 parent 11484175c8
commit bf661dffcf
2 files changed
+16 -8

No files matched your search

+8 -4
View File
@@ -165,9 +165,13 @@ export async function getNetIp(req: any) {
.json();
return { address: data[0].location, ip };
} catch (error) {
const { country, regionName, city } = await got
.get(`http://ip-api.com/json/${ip}?lang=zh-CN`)
.json();
return { address: `${country} ${regionName} ${city}`, ip };
try {
const { country, regionName, city } = await got
.get(`http://ip-api.com/json/${ip}?lang=zh-CN`)
.json();
return { address: `${country} ${regionName} ${city}`, ip };
} catch (err) {
return { address: `获取失败`, ip };
}
}
}