如何在出错时重新启动angular $ http

时间:2016-06-12 11:12:43

标签: angularjs http

我有这段代码:

handler = this.$http({
                    method: 'POST',
                    url: this._url,
                    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                    data: this._encodeParams(data),
                    cache: false,
                    responseType: 'json'
                }).error(function(data, status){

             if (data === null && status !=200) {
                        console.log('error');
                    }
                }).then(function(httpResponse) {
                    return httpResponse.data;
                });

返回处理程序;

如果服务器关闭,我需要自动重启我的请求5次。 我在{status!= 200}时尝试使用do {},但代码不起作用。

谢谢

0 个答案:

没有答案