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

WIP: Fix issue #285

commitbf8959d2d7754ff98ae54f4c1543eec1ba73a929 authorJulian Arni <jkarni@gmail.com> dateThu 10 Dec 2015, 23:44 (11 years ago) parent69c9ca4cf475c2
1 file changed+2
servant-js/src/Servant/JS/Vanilla.hs+2
servant-js/src/Servant/JS/Vanilla.hs+2
@@ -33,6 +33,8 @@ generateVanillaJSWith opts req = "\n" <>
3333 <> " var xhr = new XMLHttpRequest();\n"
3434 <> " xhr.open('" <> method <> "', " <> url <> ", true);\n"
3535 <> reqheaders
36+ <> " xhr.setRequestHeader(\"Accept\",\"application/json\");\n"
37+ <> (if isJust (req ^. reqBody) then " xhr.setRequestHeader(\"Content-Type\",\"application/json\");\n" else "")
3638 <> " xhr.onreadystatechange = function (e) {\n"
3739 <> " if (xhr.readyState == 4) {\n"
3840 <> " var value = JSON.parse(xhr.responseText);\n"