React-native Fetch(iOS)随机使HTTP请求失败,网络请求失败

时间:2019-04-24 15:27:28

标签: ios react-native fetch lets-encrypt

我越来越无法随机提取帖子https的请求。这是随机发生的,即15-20次中的1次。错误仅指出

  

网络请求失败

,仅此而已。我使用来自lets-encrypt的证书,因此我认为它满足要求。可能是什么原因?

const apiRequest = (payload, endpoint, secure ,next) => {
const address = secure ? secureServerAddress + endpoint : serverAddress + endpoint
//const address = serverAddress + endpoint
console.log('[PAYLOAD]', JSON.stringify(payload))
console.log('[ADDRESS]' ,address)
//perf.mark(endpoint);
fetch(address, getHeader(payload))  
.then((res) => {
    console.log('first res')
    return res.json()
})
.then((resJson) => {
    console.log('resJson',resJson)
    if(resJson.errorCode == 0){
        return next(null, resJson.r);
    }else{
        apiErrorHandler(resJson)
        return next(resJson.errorCode, resJson);
    }
}).catch((error)=> {
        console.log('apiRequest error',error);
        console.log('apiRequest error',error.request);
        console.error(error)
        return next(error, null);
});
}
export default apiRequest

0 个答案:

没有答案