1

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?

2
  • Looks fine to me. Commented Apr 5, 2014 at 11:15
  • @OlehPrypin So you think there might be something with me environment why it is not working? I am using the latest release of Node.js with Express and Mongo. Commented Apr 5, 2014 at 11:18

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.