Angular HttpClient "Http failure during parsing"


I try to send an POST request from Angular 4 to my Laravel backend.

My LoginService has this method:

login(email: string, password: string) {
    return``, { email, password })

I subscribe to this method in my LoginComponent:

    (response: any) => {
    (error: any) => {

And this is my Laravel backend method:


if($this->auth->attempt(['email' => $email, 'password' => $password], true)) {
  return response('Success', 200);

return response('Unauthorized', 401);

My Chrome dev tools says that my request was a success with 200 status code. But my Angular code triggers the error block and gives me this message:

Http failure during parsing for

If I return an empty array from my backend, it works… So Angular is trying to parse my response as JSON? How can i disable this?


You can specify that the data to be returned is not JSON using responseType.

In your example, you can use a responseType string value of text, like this:

    {email, password},
    {responseType: 'text'})

The full list of options for responseType is:

  • json (the default)
  • text
  • arraybuffer
  • blob

See the docs for more information.

Answered By – Kirk Larkin

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published