-3

I am calling httpClient.get. In fiddler i can see the headers for request response both have text/plain

Request:
Accept: application/json, text/plain, */*

Response:
Content-Type: text/plain; charset=utf-8

I am returning plain string "1.0.5.8" but angular tries to JSON it and throws:

SyntaxError: Unexpected token . in JSON at position 3 at JSON.parse (<anonymous>) at XMLHtt…, text: "1.0.5.8"

**How do you fix that? **(I dont want to make a json object out of simple string)..

Boppity Bop
  • 7,680
  • 10
  • 58
  • 123

1 Answers1

1

it seems Accept header doesnt work the way I think it should. So you have to force httpClient:

http.get(baseUrl + 'path/v', { responseType: 'text' }).subscribe(result => {
      this.v = result as string;
Boppity Bop
  • 7,680
  • 10
  • 58
  • 123