首页 > 解决方案 > 具有多个函数的处理程序中的“类型错误:lambda 不是函数”

问题描述

我的 handler.js 文件中有两个函数,并且在 serverless.yml 中正确配置了它们。问题是,当我运行调用时,只有第一个有效,第二个抛出类型错误:“lambda 不是函数”。

我确保我的 yml 文件或处理程序文件中没有拼写错误。另外,我尝试将函数放入单独的文件中。它们都不起作用。

在我的 handler.js 我有

const one = async (event, context, callback) => {
//code here
};

const two = async (event, context, callback) => {
//code here
};

module.exports = {
one,
two
};

在我的 yml 文件中,我有

functions:
  one:
    handler: handler.one
    events:
      - http: POST one
  two:
    handler: handler.two,
    events:
      - http: POST two

调用one工作正常,但调用two会引发错误。

标签: javascriptserverless-framework

解决方案


推荐阅读