我正在尝试使用Fetch API来处理和获取请求。到公共AWS API Gateway(无需授权)。
以下代码可以在IOS(iPhone和Ipad)上完美运行,但不能在Android上运行:
fetchData= async() =>{
const { navigation } = this.props;
const AAA = navigation.getParam('AAA',);
const route= '/info'
const response = await fetch(`${config.url}${route}?AAA=%${AAA}%`,{
method: "GET",headers: {
'x-api-key': config.key
}
});
const setdata = await response.json();
this.setState({data: setdata});
}
我目前在一个Expo Managed应用程序中,并且正在设备上通过Expo Cli进行测试。 我正在使用Expo SDK 34。 试图避免将AWS Amplify库添加到如此庞大的规模,以满足这种需求。 如果我将响应放入Console.warn(response),则会收到错误消息:
语法错误:JSON解析错误,意外的EOF解析@ [本机代码]
AWS上的CloudWatch指标甚至没有显示API被调用/到达。
我所能找到的就是: