commit
3d0ae36189
1 changed files with 4 additions and 1 deletions
|
@ -37,10 +37,13 @@ generateVanillaJSWith opts req = "\n" <>
|
||||||
<> (if isJust (req ^. reqBody) then " xhr.setRequestHeader(\"Content-Type\",\"application/json\");\n" else "")
|
<> (if isJust (req ^. reqBody) then " xhr.setRequestHeader(\"Content-Type\",\"application/json\");\n" else "")
|
||||||
<> " xhr.onreadystatechange = function (e) {\n"
|
<> " xhr.onreadystatechange = function (e) {\n"
|
||||||
<> " if (xhr.readyState == 4) {\n"
|
<> " if (xhr.readyState == 4) {\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"
|
<> " var value = JSON.parse(xhr.responseText);\n"
|
||||||
<> " if (xhr.status == 200 || xhr.status == 201) {\n"
|
|
||||||
<> " onSuccess(value);\n"
|
<> " onSuccess(value);\n"
|
||||||
<> " } else {\n"
|
<> " } else {\n"
|
||||||
|
<> " var value = JSON.parse(xhr.responseText);\n"
|
||||||
<> " onError(value);\n"
|
<> " onError(value);\n"
|
||||||
<> " }\n"
|
<> " }\n"
|
||||||
<> " }\n"
|
<> " }\n"
|
||||||
|
|
Loading…
Reference in a new issue