Even though ExpressionAttributeValues is not empty it gives me this error ValidationException: ExpressionAttributeValues must not be empty
app.post('/gpsfromuser', passport.authenticate('jwt', {session: false}), (req, res) => {
var xcorpassed = req.body.xcor
var ycorpassed = req.body.ycor
console.log(xcorpassed);
console.log(ycorpassed);
var params = {
TableName:passengers,
Key:{
"pid": req.user.id
},
UpdateExpression: "set cordx=:x, cordy=:y",
ExpressionAttributeValues:{
":x":xcorpassed,
":y":ycorpassed
},
ReturnValues:"UPDATED_NEW"
};
console.log("Updating the item...");
docClient.update(params, function(err, data) {
if (err) {
console.error("Unable to update item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("UpdateItem succeeded:", JSON.stringify(data, null, 2));
return res.status(200).json({msg: "success1"});
}
});
This error occurs if the values of the Expression Attributes are undefined.
For debugging, I had the values of the Expression Attributes printed before the params were initialized.
console.log('X Coordinate: ' + xcorpassed);
console.log('Y Coordinate: ' + ycorpassed);
I hope the answer helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With