I'm trying to do some work with Promises in Coffeescript, however, I'm getting a syntax error that I can't figure out. It doesn't seem to accept that the then
method takes two arguments.
Example:
slowTask = (num) ->
new Promise((resolve, reject) ->
if (num == 1)
resolve(num)
else
reject(num)
)
slowTask(1).then((data) -> console.log("foo"), () -> console.log("bar"))
Seems like it should work, but I'm instead getting a failure:
Error on line 9: unexpected ,
Admittedly, I'm only a few hours into coffeescript, so there may be a fundamental misunderstanding of its syntax, but as far as I can tell, it looks like the code should compile fine.
What am I missing?