【发布时间】:2020-01-12 05:08:08
【问题描述】:
我正在使用 HttpClient 请求我无法控制的服务器。
成功则返回 200 HTTP 状态码,400 为操作失败。
this.http
.post(this.getUrl(), data, { headers: headers, responseType: 'text' })
.pipe(catchError(this.handleError))
.subscribe();
handleError(error) {
error.status; // always CORS error (0) however real HTTP code is 200 or 400
...
}
例如那是成功代码
所以我的问题是,如果不可能,有什么方法可以使用 HttpClient 获取真正的 HTTP 代码而不是 CORS 错误代码,是否至少有一种方法可以在浏览器控制台中隐藏 CORS 警告消息?
【问题讨论】:
标签: angular http cors httpclient http-status-codes