0
나는 서버에서 데이터를 가져 오기 위해 fetch를 사용하고 있습니다. 서버가 응답하지 않은 경우 가져 오기 시간 초과를 설정할 수 없습니다.가져 오기 시간 초과 - 반응 원주민
내 글로벌 fetchData 클래스 내가
let resp = fetchData.fetchGetResp(restUrl, userToken);
resp.then(responseJson => {
// console.log(res);
if (responseJson != '' && responseJson != undefined) {
}
else {
console.log(responseJson);
try {
}
catch (error) {
alert(error.message);
console.log(error + 'from js file');
}
}
//Some if statement
else {
alert('Unable to Process.please try again');
}
})
.catch(error => {
alert(error.message + "Please try again after sometime");
});
내 위의 접근 방식을 기반으로하는 방법을 구현하는 제한 시간 우리를 주시기 바랍니다 fetchData
에 접근하고있어fetchGetResp(url, token) {
return fetch(url, {
method: "GET",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
})
// .then(ApiUtils.checkStatus)
.then(response =>
response.json()
)
.then(responseJson => {
return responseJson
})
.catch(error => {
// console.log(error.headers._bodyText.status);
console.log('touching undefined catch');
return undefined;
});
}
자바 스크립트 클래스입니다.
순간에 시간 제한을 지원하지 않습니다 가져 오기, 당신이 사용하는 제안합니다 [Axios의] (https://www.npmjs.com/package/axios) 또는 [api-sauce] (https://github.com/infinitered/apisauce) –