gpt4 book ai didi

android - react native (Android): Request failed with status code 403 - bscscan api testnet

转载 作者:行者123 更新时间:2023-12-04 23:57:27 26 4
gpt4 key购买 nike

请帮助我,我被这个问题困住了:我在 React Native 上使用 Axios 发出请求 BSCSCAN-API-TESTNET 并且该请求仅在 iOS 中正常工作,但它不适用于Android(403 禁止响应)。

我的 URL 请求:https://api-testnet.bscscan.com/api?module=account&action=txlist&address=0x400ee0c820144c8bb559ace1ad75e5c13e750334&sort=desc&apikey=P3A263376TPJHKQ5IXUD4VHUNFQKDJB4G5我更新了 apiKey,所以请不要介意。

我的代码:(IOS:ok,android:抛出错误 403)

try {
const url =
'https://api-testnet.bscscan.com/api?module=account&action=txlist&address=0x400ee0c820144c8bb559ace1ad75e5c13e750334&sort=desc&apikey=P3A263376TPJHKQ5IXUD4VHUNFQKDJB4G5';
const response = await axios.get(url);
} catch (error) {
throw error;
}

最佳答案

设置用户代理帮助我解决了 403 问题。

try {
const url =
'https://api-testnet.bscscan.com/api?module=account&action=txlist&address=0x400ee0c820144c8bb559ace1ad75e5c13e750334&sort=desc&apikey=P3A263376TPJHKQ5IXUD4VHUNFQKDJB4G5';
const response = await axios.get(url, {headers: { "User-Agent": "Mozilla/5.0" }});
} catch (error) {
throw error;
}

关于android - react native (Android): Request failed with status code 403 - bscscan api testnet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69277895/

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