When sending a GET request to API, I'm always getting an error (so the response will fall into the CATCH instead of TRY) even tough status is 200.
Here is the request :
// Check if user exists at blur on email input authentication
checkUserExists( platformId: string, email: string) {
return this.http.get(checkUserExistsAPI + `/${platformId}/${email}`);
}
As i'm using Angular 5, I took off the .map(res).
And here is the function that uses the request :
// Verify if emails exists
verifyEmail(email) {
if (email) {
this.authenticationService.checkUserExists( this.platformId, email )
.subscribe(
(data: CheckEmailResponse) => {
console.log(data);
},
(error: CheckEmailResponse) => {
console.log(error);
}
);
}
}
It will never console.log(data) as I'm always getting this error :
error:{
error: SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at XMLHttpRequest.onLo…, text: ""}
headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, headers: Map(0)}
message:"Http failure during parsing for http://API.com"
name:"HttpErrorResponse"
ok:false
status:200
statusText:"OK"