I'm using put and get without problems, but when it comes to delete, nothing happens. Here's my code:
async function resetUserIdDB(userId) {
let params = {
TableName: 'TableName',
"Key": {
"userId": {
"S": userId.toString()
}
}
};
try {
const dbResponse = await ddb.deleteItem(params).promise();
console.log(`dbresponse has params of ${JSON.stringify(params)} and response of ${JSON.stringify(dbResponse)}`);
if (dbResponse.Item) {
console.log(`deleted row with userId of ${userId}`);
return (dbResponse);
}
} catch (err) {
console.log(`user reset failed with ${err}`);
throw new Error(`failed to reset because of ${err}`);
}
}
The params all look fine, but I just get an empty response, and no error, but no deletion either. I'm using the same .promise() on all my other dynamodb actions.
Any ideas?
I just ran into the same problem. It seems like some of the SDK functions don't actually work unless you pass them a callback
parameter, even though it's optional. Even a function that does nothing seems to make it work. i.e.
const dbResponse = await ddb.deleteItem(params, () => {}).promise();
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