【发布时间】:2020-04-15 13:36:06
【问题描述】:
我尝试使用 Axios 方法调用 https 请求获取方法 API,从服务器响应 200,但在服务器端,API 未命中。不知道响应来自哪里,我尝试过使用邮递员的相同 API,我得到了 200 状态并正确更新了响应。之后我开始使用 react-native-debugger 来调试响应,我用网络检查器进行了调试,我尝试了相同的 API,它得到了正确的响应 200。这将是什么问题。有人,请帮我找出这个错误。
我已经使用 fetch 添加了下面的代码,同样的情况也发生在 Axios 调用中。在 react-native-debugger 中启用网络检查器时还发现了一件事,该 API 运行良好。
fetch(requestUrl, {
method: methods.get,
headers: head,
})
.then(response => response.json())
.then(responseJson => {
console.log('res JSON', responseJson);
alert('your todolist is completed!!');
}
})
.catch(error => {
console.error(error);
});
【问题讨论】:
-
您好,请分享您的代码。当你这样做时,你会更容易找到你的错误。
-
你好 Arun,正如@SylvaElendu 提到的,请分享你的代码。
-
我已在此处添加代码,感谢您的询问。这是一个简单的 get 方法,但返回错误的响应而不访问服务器。
标签: android react-native redux axios react-native-debugger