From 06306060eac3ad44ea537bfb4c2b492981b728b4 Mon Sep 17 00:00:00 2001 From: Jeremy Stucki Date: Sun, 25 Mar 2018 12:36:29 +0200 Subject: [PATCH] Handle empty responses in `json` --- src/json.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/json.js b/src/json.js index 758141d..4b64afd 100644 --- a/src/json.js +++ b/src/json.js @@ -1,5 +1,8 @@ function responseJson(response) { if (!response.ok) throw new Error(response.status + " " + response.statusText); + if (response.status === 204 || response.status === 205) { + return null; + } return response.json(); }