请帮帮我,我被这个问题卡住了:我在React Native上使用Axios请求BSCSCAN API-TESTNET,该请求只在iOS中正确工作,但它不能与安卓一起工作(403禁止响应)。
我的网址请求:https://api-testnet.bscscan.com/api?module=account&action=txlist&address=0x400ee0c820144c8bb559ace1ad75e5c13e750334&sort=desc&apikey=P3A263376TPJHKQ5IXUD4VHUNFQKDJB4G5我更新了apiKey,所以请不要介意。
我的代码:(IOS: oke,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;
}发布于 2021-10-16 06:18:37
设置用户代理帮助我解决了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;
}https://stackoverflow.com/questions/69277895
复制相似问题