From e813813d2a85cfb865c66b4a20dcedbf476c2aca Mon Sep 17 00:00:00 2001 From: SunXa <130429781+sooyaa2000@users.noreply.github.com> Date: Fri, 3 May 2024 14:48:38 +0800 Subject: [PATCH] Update index.js --- src/api/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/api/index.js b/src/api/index.js index 07ffe95..14713f8 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -46,7 +46,14 @@ export const getPlayerList = async (server, type, id) => { // 获取一言数据 export const getHitokoto = async () => { const res = await fetch("https://v.api.aa1.cn/api/yiyan/index.php"); - return await res.json(); + const text = await res.text(); + try { + const json = JSON.parse(text); // 尝试将文本转换为JSON对象 + return json; + } catch (error) { + console.error('Failed to parse text as JSON:', error); + return null; // 在无法解析JSON时返回null或适当的错误处理 + } }; /**