【发布时间】:2019-04-11 20:41:44
【问题描述】:
我想检查我编写的代码,它在发生错误 504 时重试请求(仅一次)。有人可以帮助我如何伪造错误来检查它吗? (服务器是Node express,客户端是AngularJs)。
旧代码是:
this.update = function(endpoint, body, config) {
return $http.put(endpoint, body, config || {});
};
我的新代码是:
this.update = function(endpoint, body, config) {
var updateRequest = $http.put(endpoint, body, config || {}). catch(function (error) {
if (error.status === 504){
return $http.put(endpoint, body, config || {});
}
});
return updateRequest;
};
谢谢!
【问题讨论】:
标签: angularjs node.js http express request