控制台错误读取
return context.continue;
^^^^^^
SyntaxError: Unexpected token return
我尝试添加中间件进行身份验证,我是node / js的新手,只是粘贴了示例代码,我不确定如何使用它。< / p>
// 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;
}
}
}
};
答案 0 :(得分:0)
语法错误。
// 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;
}
}
}
};