Hi all - I am trying to insert data into a collection on my site and it is failing. I’ve used the code on another site I have and it worked. On the pages where I have the import wixdata api, I get an initial error of ‘Failed to load initial data’. I fear that is a reason I am not able to do this. Has anyone else had that problem?
Here is my code to try and insert data into a collection:
// I have a field populated with the current user ID on page
// My database is called #membersDatabase or Members. I’ve tried both and neither work.
// Each time I try to insert the data, it correctly prints the toInsert variable but says ‘Your upload failed!’
export async function next2_click(event, $w) {
let toInsert = {
“uniqueUserId”: $w(“#uniqueUserId”).value,
“type”: “user”,
};
console.log(toInsert)
wixData.insert(“Members”, toInsert)
.then ( (results)=>
{
let item = results;
console.log(“You uploaded to database!”);
})
. catch ( (err)=>
{
let errorMsg = err;
console.log(“Your upload failed!”);
});
Thanks in advance!