HTTP请求多次发送

时间:2019-06-27 07:42:46

标签: angular http xmlhttprequest angular-httpclient

我正在使用角度6 我想要实现的是,单击“提交”按钮时,我将使用JSON对象命中API(该API大约需要30秒才能给出响应),并且我想显示在文本区域中获得的响应。

我遇到的问题是,单击按钮后,我收到状态为200 OK的响应,但是之后又发送了2个请求,这给出了502个代理错误,我不明白为什么这两个附加请求是去。

(请求通过apache httpd服务器请求映射(反向代理))

dummy.component.ts

public validate(logObject) {
    this.service.validateConfig(logObject).pipe(
        takeUntil(this.ngXUnsubscribe)).
        subscribe(data => {
            this._logger.warn(JSON.stringify(data));
            this.sampleResult = JSON.stringify(data); // show result obtained in a text area
        },
            error => {
                this._logger.warn("#Inside ERROR FUNCTION");
                this._logger.warn(error);
            },
            () => {
                this._logger.warn("NO ERRORS");
            });
}

dummy.service.ts

public validateConfig(logObject) {
    return this.http.post(this.url + "/dummy/validate", logObject);
}

请求:

第一个请求:

0 个答案:

没有答案
相关问题