I'm using Angular 6 to get a string from my Java REST Application and can't manage to parse/get the string
The REST API Service works just fine, it returns the String as expected, but in the Browser console I get this error
"SyntaxError: Unexpected token X in JSON at position 4 at JSON.parse"
I think this is linked to the Content-type of the Header
I've already tried to change the response type, but I can't send my data then.
login(userDTO:UserDTO):Observable<String> {
let header:HttpHeaders = new HttpHeaders({
'Content-type' : 'application/json',
});
return this.httpClient.post<String>('http://localhost:8080/login',
userDTO, {headers: header});
}
EDIT: "Where are you getting the String object from? You should be using the string literal. – Edric 2 mins"
I'm getting it from a REST Java service which returns a String Java Object