Severin
Severin

Reputation: 8588

SyntaxError: Unexpected token > in Coffeescript

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

Answers (1)

Oleh Prypin
Oleh Prypin

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

Related Questions