我正在尝试从 S3 读取 txt 文件来构建 Alexa 的响应。在 Lambda 中测试代码时,我收到此错误。谁能看到我哪里出错了?
错误
Error handled: s3.getObject is not a function
Run Code Online (Sandbox Code Playgroud)
我已经安装了“aws-sdk”,并且需要该模块位于我的技能的 index.js 顶部
const s3 = require('aws-sdk/clients/s3')
Run Code Online (Sandbox Code Playgroud)
处理程序代码。为了强调这一点,我使用 Async/Await 并在下面的 goGetS3 函数中返回一个 Promise。
const ChooseStoryIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest' &&
handlerInput.requestEnvelope.request.intent.name === 'ChooseStoryIntent';
},
async handle(handlerInput) {
let speechText;
let options = {
"Bucket": "stores",
"Key": "person.txt"
}
await goGetS3(options)
.then((response) => {
console.log(response),
console.log(response.Body.toString()),
speechText = response
})
.catch((err) => {
console.log(err)
speechText = 'something wrong getting the …Run Code Online (Sandbox Code Playgroud)