我越来越无法随机提取帖子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