Node.js coffee脚本错误:函数结尾出现意外缩进
我正在尝试制作一个REST API控制器,用于使用coffee在node.js中获取用户详细信息。 这是我的密码:Node.js coffee脚本错误:函数结尾出现意外缩进,node.js,coffeescript,Node.js,Coffeescript,我正在尝试制作一个REST API控制器,用于使用coffee在node.js中获取用户详细信息。 这是我的密码: 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:
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 }
在运行期间,它会导致指向函数最后一个字符的错误“意外缩进”
我已经仔细检查过了:所有操作都是使用空格(没有选项卡)完成的
这个错误的原因可能是什么?愚蠢的错误!
函数前有一条注释,其含义小于函数。我在中添加了两个空格,效果很好。顺便说一句,如果用命名函数替换匿名函数,该代码可能更容易阅读。@muistooshort感谢您的精彩介绍。我个人讨厌这个ORM的语法。使用回调(err,result)等标准回调比使用function().success(callback).error(callback)更容易。