gpt4 book ai didi

javascript - 语法错误: Unexpected token return

转载 作者:太空宇宙 更新时间:2023-11-04 02:14:38 25 4
gpt4 key购买 nike

Epilogue(用于 Sequelize ORM 休息端点的 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;
}
}
}
};

关于javascript - 语法错误: Unexpected token return,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36292874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com