diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-02-12 02:19:19 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-02-12 02:19:19 +0900 |
| commit | 7791dd547123b721d918d666504fdf276f0ccfc7 (patch) | |
| tree | 7a7320891985f323829afcce6fcea31ae712fad0 /src/web/app/common/scripts | |
| parent | [Server] text/plainの場合もJSONとして解析するように (diff) | |
| download | sharkey-7791dd547123b721d918d666504fdf276f0ccfc7.tar.gz sharkey-7791dd547123b721d918d666504fdf276f0ccfc7.tar.bz2 sharkey-7791dd547123b721d918d666504fdf276f0ccfc7.zip | |
[Client] Use JSON for API requests
Diffstat (limited to 'src/web/app/common/scripts')
| -rw-r--r-- | src/web/app/common/scripts/api.ls | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/web/app/common/scripts/api.ls b/src/web/app/common/scripts/api.ls index c96e51b1a8..47182b6a5a 100644 --- a/src/web/app/common/scripts/api.ls +++ b/src/web/app/common/scripts/api.ls @@ -8,7 +8,7 @@ net = riot.observable! riot.mixin \net do net: net -module.exports = (i, endpoint, data) -> +module.exports = (i, endpoint, data = {}) -> if ++pending == 1 spinner := document.create-element \div ..set-attribute \id \wait @@ -16,21 +16,12 @@ module.exports = (i, endpoint, data) -> if i? and typeof i == \object then i = i.token - body = [] - # append user token when signed in - if i? then body.push "i=#i" - - for k, v of data - if v != undefined - v = encodeURIComponent v - body.push "#k=#v" + if i? then data.i = i opts = method: \POST - headers: - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - body: body.join \& + body: JSON.stringify data if endpoint == \signin opts.credentials = \include |