我试着把记录写入我的时间流数据库。我的问题是,我得到了一个Cannot read httpResponse
的undefined,即使我做了他们在指南中描述的同样的事情:https://docs.aws.amazon.com/timestream/latest/developerguide/code-samples.write.html#code-samples.write.rejectedRecordException
const timestreamParams = {
DatabaseName: db_name,
TableName: TimeSpanRawE[table_name],
Records: chunk,
}
let request = writeClient.writeRecords(timestreamParams).promise()
await request.then(
(data) => {
return ok(data)
},
(error) => {
console.log('Error writing records:', error)
if (error.code === 'RejectedRecordsException') {
const responsePayload = JSON.parse(
//@ts-ignore
request.response.httpResponse.body.toString()
)
console.log('RejectedRecords: ', responsePayload.RejectedRecords)
console.log('Other records were written successfully. ')
}
return err({ error, params })
}
)
那么,我如何阅读错误消息?
1条答案
按热度按时间wwwo4jvm1#
您定义的请求变量不正确。promise不应该包含在request变量中。应该是这样的:
promise可以这样调用: