mirror of
https://github.com/imsyy/home.git
synced 2025-06-02 20:00:16 +09:00
Update index.js
This commit is contained in:
parent
e813813d2a
commit
1cde2e5eb3
@ -46,14 +46,8 @@ export const getPlayerList = async (server, type, id) => {
|
|||||||
// 获取一言数据
|
// 获取一言数据
|
||||||
export const getHitokoto = async () => {
|
export const getHitokoto = async () => {
|
||||||
const res = await fetch("https://v.api.aa1.cn/api/yiyan/index.php");
|
const res = await fetch("https://v.api.aa1.cn/api/yiyan/index.php");
|
||||||
const text = await res.text();
|
const text = await res.text(); // 使用.text()方法而不是.json()
|
||||||
try {
|
return text;
|
||||||
const json = JSON.parse(text); // 尝试将文本转换为JSON对象
|
|
||||||
return json;
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to parse text as JSON:', error);
|
|
||||||
return null; // 在无法解析JSON时返回null或适当的错误处理
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user