我能找到答案,所以我想我会把它贴在这里,让任何人都能找到答案。
我定义
params
不正确。下面是有效的Javascript代码:
AWS.config.update({
region: "us-west-2",
endpoint: 'https://dynamodb.us-west-2.amazonaws.com',
accessKeyId: "Fakeaccesskey",
secretAccessKey: "Fakesecretkey"
});
var docClient = new AWS.DynamoDB.DocumentClient();
function readItemtesttwovalues() {
var params = {
TableName: "TA_Log1",
IndexName: "ID-GWID-index",
KeyConditionExpression: "ID = :id and GWID = :gwid",
ExpressionAttributeValues: {
":id": "BB00000013",
":gwid": "AA00000001"
},
ScanIndexForward: false,
Limit: 1
};
docClient.query(params, function(err, data) {
if (err) {
document.getElementById('testtwostatus').innerHTML = "Unable to read item: " + "\n" + JSON.stringify(err, undefined, 2);
} else {
document.getElementById('testtwostatus').innerHTML = data.Item.Status;
document.getElementById('testtwotemp').innerHTML = data.Item.Temp;
document.getElementById('testtwotempmap').innerHTML = data.Item.Temp;
document.getElementById('testtwohum').innerHTML = data.Item.Hum;
document.getElementById('testtwohummap').innerHTML = data.Item.Hum;
document.getElementById('testtwobat').innerHTML = data.Item.BatV;
document.getElementById('testtwobatmap').innerHTML = data.Item.BatV;
var temp = Number(data.Item.Temp);
}
});
}