Skip to content

Instantly share code, notes, and snippets.

@markomanninen
Created November 5, 2011 19:50
Show Gist options
  • Save markomanninen/1341932 to your computer and use it in GitHub Desktop.
Save markomanninen/1341932 to your computer and use it in GitHub Desktop.
why function returns object object, not string?
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
@markomanninen
Copy link
Author

my solution:

spun = (msg, spinner = null) ->
...
if spinner
msg.send spinner body.message
else
msg.send body.message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment