You are running an wixData.update inside the return funtion of the wixData.query, I think you will need to make the update end with .then() you know and put the code that should run after the update inside that. If you d onot nest them correctly errors might occur. Another solution would be to use async and await and break everything out to smaller functions. Just make sure you console.log(”I am here now”) and you might be able to track down wher ethe error occurs. Also try to use the catch to see where and what triggers the error.
I cant see all the code just the top parts