From a15d1d931451125770928de79dc676b647220985 Mon Sep 17 00:00:00 2001 From: Arian van Putten Date: Sun, 27 Dec 2015 14:05:32 +0100 Subject: [PATCH 1/2] Fix 294 --- servant-js/src/Servant/JS/Vanilla.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/servant-js/src/Servant/JS/Vanilla.hs b/servant-js/src/Servant/JS/Vanilla.hs index 22b29b4c..0179f16f 100644 --- a/servant-js/src/Servant/JS/Vanilla.hs +++ b/servant-js/src/Servant/JS/Vanilla.hs @@ -37,10 +37,13 @@ generateVanillaJSWith opts req = "\n" <> <> (if isJust (req ^. reqBody) then " xhr.setRequestHeader(\"Content-Type\",\"application/json\");\n" else "") <> " xhr.onreadystatechange = function (e) {\n" <> " if (xhr.readyState == 4) {\n" + <> " if (xhr.status == 204) {\n" + <> " onSuccess();\n" + <> " } else if (xhr.status >= 200 && xhr.status < 300) {\n" <> " var value = JSON.parse(xhr.responseText);\n" - <> " if (xhr.status == 200 || xhr.status == 201) {\n" <> " onSuccess(value);\n" <> " } else {\n" + <> " var value = JSON.parse(xhr.responseText);\n" <> " onError(value);\n" <> " }\n" <> " }\n" From 82fa23507f9475791e6a19f68ff0320755ee4be9 Mon Sep 17 00:00:00 2001 From: Arian van Putten Date: Sun, 27 Dec 2015 17:23:46 +0100 Subject: [PATCH 2/2] Add 205 --- servant-js/src/Servant/JS/Vanilla.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servant-js/src/Servant/JS/Vanilla.hs b/servant-js/src/Servant/JS/Vanilla.hs index 0179f16f..ea390e2f 100644 --- a/servant-js/src/Servant/JS/Vanilla.hs +++ b/servant-js/src/Servant/JS/Vanilla.hs @@ -37,7 +37,7 @@ generateVanillaJSWith opts req = "\n" <> <> (if isJust (req ^. reqBody) then " xhr.setRequestHeader(\"Content-Type\",\"application/json\");\n" else "") <> " xhr.onreadystatechange = function (e) {\n" <> " if (xhr.readyState == 4) {\n" - <> " if (xhr.status == 204) {\n" + <> " if (xhr.status == 204 || xhr.status == 205) {\n" <> " onSuccess();\n" <> " } else if (xhr.status >= 200 && xhr.status < 300) {\n" <> " var value = JSON.parse(xhr.responseText);\n"