问题描述
如果不是Bug或我的代码有问题,我不会。但是第一次获取需要很长时间才能做出响应。 尽管此问题仅在应用程序上。当我在网络上运行它时,它就像一个超级按钮并在2到3秒钟内加载。在应用程序上花费的时间超过一分钟。
fetch(url)
.then((response)=>response.json() )
.then((responseJson)=>{
setDATA(responseJson);
setLoading(false);
})
.catch((err)=>{
console.log(err)
})
我也使用过Axios,但是有同样的问题
axios.get(url)
.then(res => {
setDATA(res.data);
setLoading(false)
console.log(DATA);
})
如果您认为这可能是大数据问题。 sql数据库只有2个字段可从中获取。 而且,当我尝试登录用户时也是如此。同样缓慢的获取和缓慢的响应
fetch(url,{
method: 'POST',headers: {
'Accept': 'application/json','Content-Type': 'application/json',},body: JSON.stringify({
email: email,password: password
}),})
.then(response => response.json())
.then((responseJson) => {
setLoading(false);
// If server response message same as Data Matched
if (responseJson === 'Data Matched') {
// save user to async
// AsyncStorage.setItem('isLoggedIn',true);
//send user to main page
navigation.navigate('flatlist');
} else {
alert(responseJson);
console.log(responseJson)
}
})
.catch((error) => {
setLoading(false);
console.log(error);
});
};
当我阅读this
时,这似乎也像是个错误。解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)