[英]How to manipulate an error in http Angular before propagating it again?
我正在使用NativeScript和Angular编写应用程序。 我正在将旧的AngularJS应用迁移到我的新应用。 我有一个HTTP请求要调用,如果此特定端点有错误,则要在传播之前对其进行操作。
如何在Angular 2+中实现呢?
return $http
.post(
url.concat(endpoint),
_params,
CONSTANTS.httpDefaults
)
.then(function (response) {
return response;
})
.catch(function (error) {
ErrorMessageAndDebugLogService.logDebugError(error, endpoint);
if (error.data != null && error.data.Message != null &&
error.data.Message.indexOf('No HTTP resource was found that matches the request URI') !== -1) {
error = 'This feature is not available in this version of Softworks product. Please contact your local administrator for more information.';
}
return $q.reject(error);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.