-2

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)..

1
  • its not the same. the POST issue is a different problem and is well documented on github. but whatever Commented Feb 26, 2021 at 14:08

1 Answer 1

2

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;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.