Reputation: 8588
I just started learning Coffeescript and have syntax error that I can't figure out. I have written the following code:
exports.list = (req, res) ->
User.find({}).select('username').exec (err, results) ->
if err
res.send(err)
else
console.log(results)
viewData =
title: 'Users'
users: results
res.render 'users', viewData
return
return
When executed it throws SyntaxError: Unexpected token > on line 1
, but as far as I know this should be the right syntax for Coffeescript?
Upvotes: 1
Views: 2554
Reputation: 34116
The code is valid CoffeeScript.
It appears that whatever is executing this code is expecting JavaScript, not CoffeeScript. By pasting your code into a JavaScript console I got the exact same error.
Upvotes: 3