gpt4 book ai didi

javascript - 如何设置此 API 获取请求?

转载 作者:行者123 更新时间:2023-12-01 03:36:40 25 4
gpt4 key购买 nike

我正在尝试让一个 API 正常工作,该 API 可从该网站获取琐碎问题:https://opentdb.com/api_config.php 。这是我的代码:

if (auth && data.user == user && match('trivia', data.msg)) {
$("button").click(function() {
$.get("https://opentdb.com/api.php?amount=10&token=d6685dc31db69e33eeb1c3828ffa2c587d5ec43dc6dd995ebefe85681796d149", function(data, status) {
sock.chat("Data: " + data + "\nStatus: " + status);
});
});
}

它没有“sock.chat”任何东西,我对此很陌生,如果有明显的错误,我很抱歉。如果有帮助的话,我正在网站上的 Tampermonkey 上使用这个脚本。

最佳答案

这是一个工作示例:

const url = "https://opentdb.com/api.php?amount=10&token=d6685dc31db69e33eeb1c3828ffa2c587d5ec43dc6dd995ebefe85681796d149";


fetch(url)
.then(res => res.json())
.then(json => console.log(json.results))
.catch(error => console.error(error))

关于javascript - 如何设置此 API 获取请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44225584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com