git.iko.soy/typeable/servant
on master help sign in
Merge pull request #310 from arianvp/294

Fix #294

commit3d0ae36189b2b633fe992a22ae2fce857ffd6fad authorJulian Arni <jkarni@gmail.com> dateThu 7 Jan 2016, 13:00 (11 years ago) parentec60b5582fa235
1 file changed+4−1
servant-js/src/Servant/JS/Vanilla.hs+4−1
servant-js/src/Servant/JS/Vanilla.hs+4−1
@@ -37,10 +37,13 @@ generateVanillaJSWith opts req = "\n" <>
3737 <> (if isJust (req ^. reqBody) then " xhr.setRequestHeader(\"Content-Type\",\"application/json\");\n" else "")
3838 <> " xhr.onreadystatechange = function (e) {\n"
3939 <> " if (xhr.readyState == 4) {\n"
40+ <> " if (xhr.status == 204 || xhr.status == 205) {\n"
41+ <> " onSuccess();\n"
42+ <> " } else if (xhr.status >= 200 && xhr.status < 300) {\n"
4043 <> " var value = JSON.parse(xhr.responseText);\n"
41− <> " if (xhr.status == 200 || xhr.status == 201) {\n"
4244 <> " onSuccess(value);\n"
4345 <> " } else {\n"
46+ <> " var value = JSON.parse(xhr.responseText);\n"
4447 <> " onError(value);\n"
4548 <> " }\n"
4649 <> " }\n"