Re: [whatwg/fetch] 204 and json (#113)

I'm dealing with GitHub's [followers API](https://developer.github.com/v3/users/followers/#check-if-one-user-follows-another) and it returns empty responses as 404 or 204.

This is my solution:

```js
const content = await response.text();
const json = content.length > 0 ? JSON.parse(content) : {};
```

---

Aside: I think that **fetch**'s behavior is correct and APIs are breaking the contract by not sending valid JSON (`JSON.parse('')` also fails)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/113#issuecomment-420865656

Received on Thursday, 13 September 2018 02:49:52 UTC