Reputation: 226
I am trying to make a REST API controller for getting user details in node.js using coffee. Here is my code:
get_get: (req, res, params)->
@m_auth.can req.user, ['SUPER_USERS_GET'], (err, result)=>
if err? || !result? || !result
console.log err
return res.send 401, { message: constants.auth.no_privs }
if !params? || !params['username']?
return res.send 400, { message: constants.params.no_mandatory }
@User.find
where:
username: params['username']
.success (user)->
user.getPrivs()
.success (privs)->
user.dataValues.privs = privs
return res.send 200, user.dataValues
.error (err)->
console.log err
user.dataValues.privs = null
return res.send 200, user.dataValues
.error (err)->
console.log err
return res.send 500, { message: constants.server.internal_error }
During run it causes error "unexpected indentation" pointing to the last character of the function.
I have double-checked already: all intends are done using white spaces (no tabs).
What might be the reason for this error?
Upvotes: 0
Views: 2104
Reputation: 226
Stupid mistake! There was a comment right before the function with intend less than a function. I added two spaces and in worked fine.
Upvotes: 1