You need to enable JavaScript to run this app. Chrome浏览器调用币安Binance API执行fetch请求异常问题排查
优惠活动
大模型
产品
解决方案
定价
更多

Chrome浏览器调用币安Binance API执行fetch请求异常问题排查

我的代码在anWriter应用中运行正常,但在Chrome浏览器中无法正常运行!

代码执行到Account_Fetch函数中的fetch行后就出现卡顿无响应的情况,如果代码运行正常,会弹出OK提示消息。

相关文档

  • Endpoint Security Type
  • SIGNED Endpoint Security
  • Timing Security
  • Account Information

注意:本账号为测试账号,因此公开API Key和Secret Key。

对应代码

<html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.js"></script>
<script>
let AccessKey="1q02kgTluaKFYH9vgBAQyIIIN7UmSSCZvI8dELzM4RsNR3WEWJJqb6cIdaPVkYjE";
let SecretKey="IFcsWGidd6WQFZMKlUMd9fzTn0ztBV8esRl1BSz5O9vrKClrlDXorVAxUxJGWkwk";
let ServerTime=0;
let MaxDelay=60000;

Process();

async function Process()
{
await Time_Fetch();
await Account_Fetch(AccessKey,SecretKey,ServerTime,MaxDelay);

alert("OK");
}

async function Time_Fetch()
{
let URL="https://api.binance.com/api/v3/time";
let Request=URL;

let Fetch=await fetch(Request);
let JSON=await Fetch.json();
let Data=await JSON;

ServerTime=parseInt(Data.serverTime);
}

async function Account_Fetch(AccessKey,SecretKey,ServerTime,MaxDelay)
{
let URL="https://api.binance.com/api/v3/account";
let Parameters="timestamp="+ServerTime+"&"+"recvWindow="+MaxDelay;
let Signature=CryptoJS.HmacSHA256(Parameters,SecretKey);
let Request=URL+"?"+Parameters+"&"+"signature="+Signature;

let Fetch=await fetch(Request,{method:"get",headers:{"X-MBX-APIKEY":AccessKey}});
let JSON=await Fetch.json();
let Data=await JSON;
}
</script>
</html>

内容的提问来源于stack exchange,提问作者Clean Code

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.12 11:06:01