Typescript 造成';未处理的承诺拒绝:TypeError';在奥雷利亚?
我已经进入奥雷利亚发展,但休息了两个月。现在,我在it中启动了一个新项目,在尝试使用Typescript 造成';未处理的承诺拒绝:TypeError';在奥雷利亚?,typescript,http,request,aurelia,Typescript,Http,Request,Aurelia,我已经进入奥雷利亚发展,但休息了两个月。现在,我在it中启动了一个新项目,在尝试使用HTTPFetchClient时遇到了一个未知问题 控制台显示: aurelia-fetch-client.js?a909:199 OPTIONS http://url.com/api/login net::ERR_CONNECTION_REFUSED index.js?07f7:248 Possible Unhandled Promise Rejection: TypeError: Failed to fet
HTTPFetchClient
时遇到了一个未知问题
控制台显示:
aurelia-fetch-client.js?a909:199 OPTIONS http://url.com/api/login net::ERR_CONNECTION_REFUSED
index.js?07f7:248 Possible Unhandled Promise Rejection: TypeError: Failed to fetch
“网络”选项卡显示:
Request URL: http://url.com/api/login
Referrer Policy: no-referrer-when-downgrade
令我惊讶的是,我以前的项目(两个月前成功执行fetch client请求)现在也显示了这个错误。
有人能对这个问题给出见解吗?
为什么我会遇到这种情况 听起来你在做async/await,你还没有在
try/catch
中包装你的await
调用
有些版本的Aurelia使用Bluebird作为承诺垫片,您可以使用它们来处理这些问题
这是它的样子
// NOTE: event name is all lower case as per DOM convention
window.addEventListener("unhandledrejection", function(e) {
// NOTE: e.preventDefault() must be manually called to prevent the default
// action which is currently to log the stack trace to console.warn
e.preventDefault();
// NOTE: parameters are properties of the event detail property
var reason = e.detail.reason;
var promise = e.detail.promise;
// See Promise.onPossiblyUnhandledRejection for parameter documentation
});
// NOTE: event name is all lower case as per DOM convention
window.addEventListener("rejectionhandled", function(e) {
// NOTE: e.preventDefault() must be manually called prevent the default
// action which is currently unset (but might be set to something in the future)
e.preventDefault();
// NOTE: parameters are properties of the event detail property
var promise = e.detail.promise;
// See Promise.onUnhandledRejectionHandled for parameter documentation
});
当然,您可能使用了不同的方法。但是,归根结底,
try/catch
是你的答案 您的服务器已关闭。