Hi,
So I have this code on my WebSite in lots of pages and it always worked. But a few days ago I have noticed some issues and when I looked at the console I saw an error saying “Uncaught (in promise) TypeError: Cannot read property ‘then’ of undefined”.
When I remove the “.then(() => {” it works again. But why doesn’t it work now with the “then”?
According to the wix docs…
setFieldValue doesn’t return a promise.
This function changes the current item in the data set BUT doesn’t commit the change until you save() it.
It’s the save() that returns a Promise that you can perform a .then() on.
Perhaps you removed a save() call???
No I haven’t changed the code for a long time.
OK well the problem is that setFieldValue() doesn’t return a promise which means that you are calling then from an undefined object.
Perhaps wix determined that the save() function was the area that a promise was really needed and changed it at some point?
I just know that I have updated all my code and now it’s working again.