如何从HEAD请求的响应头访问状态代码

时间:2018-04-09 10:37:13

标签: javascript angular typescript http

我正在尝试访问HEAD请求的状态代码。我如何访问相同的?

  getNameObj(queryStr: string): Promise<any> {
   return this.http.head(endpoints.getNamesUrl(queryStr))
      .toPromise()
      .then(this.handleResponse)
      .catch(this.handleError);
  }

  private handleResponse(response: HttpResponseBase): Promise<any> {
    console.log(response.status)
    return Promise.resolve(response);
  }

  private handleError(error: HttpErrorResponse): Promise<any> {
    return Promise.reject(error);
   }

Alos,我收到错误ERROR Error: Uncaught (in promise): SyntaxError: Unexpected token o in JSON at position 1 SyntaxError: Unexpected token o in JSON at position 1...

0 个答案:

没有答案