我开始尝试用 node 和 puppeteer 编写一个 lambda 函数。我正在使用无服务器框架。
在我的 handler.js 中:
exports.detail = async (event, context) => {
console.log(event);
let id = event.pathParameters.id || 1;
console.log(id);
我一直在尝试使用 event 参数传入 id 参数,但如果未设置,我希望将值设置为 1 。但是当我尝试时:
$ sls invoke local -f detail
{
"errorMessage": "Cannot read property 'id' of undefined",
"errorType": "TypeError",
"stackTrace": [
"TypeError: Cannot read property 'id' of undefined",
我怎样才能得到这个工作?
慕桂英4014372
相关分类