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.
Hey,
After finishing with the updating the collection, you should return the relevant value. It seems like you’ve returned the promise but inside the “then” part you haven’t returned anything.
If it’s unclear, paste here the rest of the code and I’ll try to explain it better with your code.
Moreover, as Andreas mentioned, I recommend splitting the code to smaller functions. It will help you with debugging your code.
Have you tried returning the toUpdate variable after updating the relevant collection? (line 30). Moreover, I recommend using Postman chrome extension to check the get and post requests.
Hi,
When using HTTP requests, you should return a response and not a JSON object. For that purpose, you can use the OK response as explained here . Make sure to set the header response and an informative message so that you know if the object was updated or not: