File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import Data.Text (Text)
7
7
import Data.Text.Encoding (decodeUtf8 )
8
8
import qualified Data.Text as T
9
9
import Data.Monoid
10
- import Servant.Foreign
10
+ import Servant.Foreign hiding ( header )
11
11
import Servant.JS.Internal
12
12
13
13
-- | Generate vanilla javascript functions to make AJAX requests
@@ -34,7 +34,7 @@ generateVanillaJSWith opts req = "\n" <>
34
34
<> " xhr.open('" <> decodeUtf8 method <> " ', " <> url <> " , true);\n "
35
35
<> reqheaders
36
36
<> " xhr.setRequestHeader('Accept', 'application/json');\n "
37
- <> (if isJust (req ^. reqBody) then " xhr.setRequestHeader('Content-Type', 'application/json');\n " else " " )
37
+ <> (if isJust (req ^. reqBody) && (req ^. reqBodyContentType == ReqBodyJSON ) then " xhr.setRequestHeader('Content-Type', 'application/json');\n " else " " )
38
38
<> " xhr.onreadystatechange = function () {\n "
39
39
<> " var res = null;\n "
40
40
<> " if (xhr.readyState === 4) {\n "
@@ -79,7 +79,7 @@ generateVanillaJSWith opts req = "\n" <>
79
79
80
80
dataBody =
81
81
if isJust (req ^. reqBody)
82
- then " JSON.stringify(body)"
82
+ then if (req ^. reqBodyContentType == ReqBodyJSON ) then " JSON.stringify(body)" else " body "
83
83
else " null"
84
84
85
85
You can’t perform that action at this time.
0 commit comments