Nested then to read and update database

Hello Everyone,

I have this code to read an entry of the db with the _id and update one of its column. Its not working. Any help on this is really appreciated.

async function findAction(actionID) {
const action = await wixData.get(“Actions”, actionID);
return action;
}
// Share it button click
export function button6_click(event) {
const actionID = local.getItem(“actionId”);
findAction(actionID)
.then((item) => {
console.log(“got action:” + item);
const userInputs = item.endUserInputs;
item.endUserInputs = userInputs + “+shareIt=” + $w(‘#textBox3’).value;
console.log(item._id);
console.log("updating with new user inputs without: " + item.endUserInputs);
wixData.save(“Actions”, item);
//wixData.update(“Actions”, item)
})
.then((results) => {
console.log(“really updated”);
console.log(“updated database”);
$w(‘#text8’).show();
})
. catch ( (err) => {
let errorMsg = err;
console.log(errorMsg);
}
);
}

Hi,

The get and save code seems to have no obvious glitch in it. What is catching my eye is that you refer to the locally stored data item as actionId but then name the constant actionID with “ID” capitalized. I’m wondering if the stored data item is actually actionID?