SyntaxError:意外的令牌返回
SyntaxError: Unexpected token return
Epilogue(Sequelize ORM rest endpoint的npm模块)只有5个月的历史,因此文档很少,但我想知道如何使用它的npm页面上的这个示例中间件模块https://www.npmjs.com/package/epilogue
控制台错误读取
return context.continue;
^^^^^^
SyntaxError: Unexpected token return
我正在尝试添加用于身份验证的中间件,我是node/js的新手,刚开始粘贴了示例代码,我不知道如何使用它。
// middleware.js
module.exports = {
create: {
fetch: function(req, res, context) {
// manipulate the fetch call
console.log('Request URL:', req.originalUrl);
next();
}, function (req, res, next) {
console.log('Request Type:', req.method);
next();
}
return context.continue;
}
},
list: {
write: {
before: function(req, res, context) {
// modify data before writing list data
return context.continue;
},
action: function(req, res, context) {
// change behavior of actually writing the data
return context.continue;
},
after: function(req, res, context) {
// set some sort of flag after writing list data
return context.continue;
}
}
}
};
语法错误。
// middleware.js
module.exports = {
create: {
fetch: function(req, res, context) {
// manipulate the fetch call
console.log('Request URL:', req.originalUrl);
console.log('Request Type:', req.method);
return context.continue;
}
},
list: {
write: {
before: function(req, res, context) {
// modify data before writing list data
return context.continue;
},
action: function(req, res, context) {
// change behavior of actually writing the data
return context.continue;
},
after: function(req, res, context) {
// set some sort of flag after writing list data
return context.continue;
}
}
}
};
相关文章:
- 函数返回错误'令牌{'
- AngularJS $http GET 请求到本地 JSON 文件返回语法错误:意外令牌]
- “JSON.parse(str)”返回“意外令牌c”,但str是一个字符串
- angularjs-SyntaxError:请求从服务器返回时出现意外令牌
- SyntaxError:意外的令牌返回
- PHP调用脚本函数,返回值为Uncaught SyntaxError:意外的令牌ILLEGAL
- AngularJS身份验证,带有一个restful api,成功时返回一个令牌
- 条纹令牌没有返回到我的表单
- 在 Ajax 调用中解析返回数据时出现令牌错误
- 跨 ajax 请求到服务器返回的 json 对象显示错误意外令牌:
- JWT 返回无效签名错误,即使我在授权中输入令牌也是如此
- Chrome 扩展程序:未捕获语法错误:意外的令牌返回
- 返回哈希时出现意外的令牌 { 错误
- Chrome 返回“语法错误:意外令牌”
- '意外的令牌'箭头函数返回的对象中存在语法错误
- Bing映射API请求返回未压缩的SyntaxError:意外的令牌:
- 将存储在cookie中的令牌发送到服务器并获得布尔值返回
- 简单的facebook注销返回调用没有访问令牌
- pub历史API调用总是返回时间令牌
- 通过jquery ajax返回的JSON数据上的意外令牌u