1

Have no idea why I am getting this error but my code:

angular.module('authAppApp')
  .factory 'AuthService', (Session) ->
    # Service logic
    # ...



    # Public API here
    {
      login: (creds)->


        res =  
              id: 1, 
              user: 
                id: 1,
                role: "admin"



            Session.create(res.id, res.user.id, res.user.role)
            return 


    }

Error:

[stdin]:30:14: error: unexpected .
            Session.create(res.id, res.user.id, res.user.role)
             ^

This also happens with console.log Why?

1 Answer 1

3

It looks like your indentation is off:

    res =  
          id: 1, 
          user: 
            id: 1,
            role: "admin"



        Session.create(res.id, res.user.id, res.user.role)
        return

The indentation of Session should match the indentation of res =. Otherwise, the coffeescript compiler will parse it as a property of the object you are setting res to. In particular, it's probably expecting a : and a value after Session.

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.