我收到“getEventPrediction”不是函数的错误。我正在关注 AWS 文档,但不知道为什么。
这是我遵循的文档:
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/FraudDetector.html
这是我在运行 Lambda 测试事件时遇到的错误:
2020-10-09T21:01:54.151Z a5c86d6f-9347-49ec-9fe9-4124cd976953 错误调用错误 {"errorType":"TypeError","errorMessage":"frauddetector.getEventPrediction 不是函数","stack":[ “TypeError:欺诈检测器.getEventPrediction 不是函数”,“在 Runtime.exports.handler (/var/task/index.js:18:18)”,“在 Runtime.handleOnce (/var/runtime/Runtime.js: 66:25)"]}
这是 Lambda 函数:
const AWS = require('aws-sdk')
const frauddetector = new AWS.FraudDetector();
exports.handler = async (event) => {
frauddetector.getDetectors();
console.log('getDetectors worked 3');
var params = {
detectorId: 'new_account_fraud_detector',
eventId:'123456789',
eventTimestamp: '2020-07-13T23:00:03Z',
eventTypeName: 'new_customer_registration',
eventVariables: {'email_address':'fake_jamie11@example.com', 'ip_address':'1.2.3.4'},
entities: [ {entityType:'customer', entityId:'12345'} ]
};
frauddetector.getEventPrediction(params, function (err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
// TODO implement
const response = {
statusCode: 200,
body: JSON.stringify('FraudDetector : ran'),
};
return response;
};