node.js - 通过 Express / 节点内的 AWS SDK 扫描 DDB 时的 Request.HTTP_DATA
问题描述
我正在设置一个访问 AWS DynamoDB 的 Node Express API,但我遇到了一些问题。
我仍在学习如何最好地处理异步/等待,但我无法弄清楚为什么下面的代码:
app.get("/vibefinder-photos", asyncWrapper(async (req) => {
console.log('getting photos')
let output = await getVibefinderPhotos();
return output;
}));
async function getVibefinderPhotos() {
const params = {
TableName: "vibefinder-photos",
};
try {
const r = await dynamodb.scan(params, function (err, data) {
if (err) {
console.log("Error scan ", err);
} else {
console.log(data)
}
}).promise();
return r;
} catch (e) {
console.log(e);
}
}
引发以下错误:
Error scan Error [TypeError]: Cannot read property 'push' of undefined
at Request.HTTP_DATA (/Users/nickwoods/Documents/GitHub/nodeapi/node_modules/aws-sdk/lib/event_listeners.js:418:35)
at Request.callListeners (/Users/nickwoods/Documents/GitHub/nodeapi/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/Users/nickwoods/Documents/GitHub/nodeapi/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/Users/nickwoods/Documents/GitHub/nodeapi/node_modules/aws-sdk/lib/request.js:688:14)
at IncomingMessage.onReadable (/Users/nickwoods/Documents/GitHub/nodeapi/node_modules/aws-sdk/lib/event_listeners.js:318:32)
at IncomingMessage.emit (node:events:394:28)
at IncomingMessage.emit (node:domain:470:12)
at emitReadable_ (node:internal/streams/readable:573:12)
at onEofChunk (node:internal/streams/readable:551:5)
at readableAddChunk (node:internal/streams/readable:267:5) {
code: 'TypeError',
time: 2021-09-29T05:46:30.754Z,
statusCode: 200,
retryable: false,
retryDelay: 61.83578978099382
}
解决方案
推荐阅读
- python - 如果我断开连接,Google Colab 会继续运行单元以将文件保存在已安装的驱动器中吗?
- postgresql - 是否可以每月添加每种类型的累积总和?
- openlayers - 如何在openLayers的折线中添加样式?
- css - 从 mat-form-field 中填充和删除边距的正确方法
- linker - 在 Uno WASM 中序列化 JSON 时“找不到构造函数”
- mysql - Mysql查询特定日期和时间范围
- python-3.x - 如何在 pyTelegramBotApi 中制作自定义 callback_data?
- java - 我获取数据但无法在 textview 中显示数据
- swift - swift中的多任务处理功能
- python - 如何更改神经网络中的 dtype