Created
November 5, 2011 19:50
-
-
Save markomanninen/1341932 to your computer and use it in GitHub Desktop.
why function returns object object, not string?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spun = (msg) -> | |
timestamp = gmdatenow() | |
signature = get_signature(host, path, secret_key, access_key, timestamp, version) | |
msg.http(scheme + "://" + host + path) | |
.query | |
timestamp: timestamp | |
version: version | |
access_key: access_key | |
signature: signature | |
type: 'json' | |
.post(msg.match[1]) (err, res, body) -> | |
if err | |
msg.send err | |
else if res.statusCode is not 200 | |
msg.send "Service not available! Status code: " + res.statusCode | |
else | |
# set to the memory so user can spin it with separate "spin the last spun" command | |
body = JSON.parse(body) | |
if body.response is 'error' | |
msg.send body.message | |
msg.send body.data | |
else | |
msg.send body.message | |
body.message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my solution:
spun = (msg, spinner = null) ->
...
if spinner
msg.send spinner body.message
else
msg.send body.message