1

I am trying to access the status code for the HEAD request. How do I access the same?

  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, I am getting an error ERROR Error: Uncaught (in promise): SyntaxError: Unexpected token o in JSON at position 1 SyntaxError: Unexpected token o in JSON at position 1...

MelDsz
  • 179
  • 4
  • 14
  • 2
    If you search for the error message with your preferred search provider you will get a _huge_ load of answers. – Andreas Apr 09 '18 at 10:41
  • You can refer https://stackoverflow.com/questions/38380462/syntaxerror-unexpected-token-o-in-json-at-position-1 – nerding_it May 03 '18 at 08:56

0 Answers0