我有一个功能
const integration = async (event) => {
const user = await authenticateUser({
email,
password,
})
const authentication = path(['idToken', 'jwtToken'], user)
return Promise.all(reduce(async (prevEvent, endpointId) => {
const endpointDesc = endpoints[endpointId]
let apiEvent = endpointDesc.actionEvent
apiEvent.authentication = authentication
if (endpointDesc.parameters.length > 0) {
apiEvent = reduce((eventAcc, param) => {
const prevPayload = eventAcc.payload
const newPayload = { prevPayload, [param]: prevEvent.body[param] }
return { ...apiEvent, payload: newPayload }
}, apiEvent, apiEvent.parameters)
}
const lambdaParams = {
FunctionName: apiFunctionArn,
Payload: apiEvent,
}
const lambdaRes = await lambda.invoke(lambdaParams).promise()
return lambdaRes
}, Promise.resolve(), event.endpointId))
}
错误是undefined is not a function
lambda.invoke
是导致错误的代码段
lambda
对象来自const lambda = new AWS.Lambda()
(aws-sdk
)
lambda.invoke
,在与return Promise.all(reduce(async (prevEvent, endpointId) => {
匹配的行之前,应该起作用
我已经尝试过lambda.invoke.bind(lambda)之类的东西,但是老实说我最后一次完全忘记了面向对象的javascript:X
如果这很有意义,我使用reduce
中的ramda
感谢前进!