我正在从我的Angular2站点查询一些elasticsearch服务器。为了提高安全性,我们希望将访问权限锁定为仅GET请求。Elasticsearch支持GET with a body,但是我在使用Angular2的http类时遇到了麻烦。this.http.post(SearchEndpoint, q.BuildPayload(), { method: 'GET' })
因为http
在使用角HttpClient post时,默认情况是将响应视为JSON字符串。即使在响应体为空时,当响应体为空字符串""失败JSON.parse()时,也会导致错误。但是,当请求失败时,端点确实返回中的错误描述(即在成功时为空,在错误时为JSON )。.subscribe(() => {
// do something for success, no return obje