# Angular: Http failure during parsing for http://…: SyntaxError: Unexpected token '<' (response is not JSON)

**Code:** `Http failure during parsing` · **Category:** Angular · **Seen on:** Angular, TypeScript

The request succeeded (status 200) but the body could not be parsed as the expected type — usually HTML or plain text instead of JSON.

## Meaning

`HttpClient` parses responses as JSON by default. If the server returns an HTML page (proxy error, login redirect, SPA fallback) or plain text, parsing fails with `Http failure during parsing`. Use `responseType: 'text'` for text endpoints, or fix the URL so the API returns JSON.

## Common causes

- The URL returns HTML (the SPA `index.html` or an error page)
- Endpoint returns plain text or an empty body with a JSON default
- Wrong `Accept` header or response type
- API returns invalid JSON (trailing comma, BOM)
- Proxy/redirect to a login page

## Quick fix

1. Open the URL in the browser or curl and check the body
2. Set `responseType: 'text'` (or 'blob') where JSON is not returned
3. Fix the endpoint or proxy path so it returns JSON

## Detailed fix by platform

### Angular

1. `this.http.get(url, { responseType: 'text' })` for text responses
2. Debug: `curl -i -H "Accept: application/json" https://api.example.com/x`

## Code examples

### Plain text endpoint

```typescript
this.http.get('/api/version', { responseType: 'text' }).subscribe(v => console.log(v));   // "1.4.2"
```

## How to diagnose

1. **Body** — What does curl return?
2. **Type** — JSON or text?
3. **Path** — Is a proxy returning HTML?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/http-failure-during-parsing)
