I have been staring for hours at this, put console.log´s everywhere, read the Wix article about backend debugging (which is like giving sheet music to a carpenter for me), but I cannot find the source of the problem: a backend function that should return a Boolean, returns a Promise and all console.log´s inside it are not shown in browser console.
Could somebody at Wix have a look at this, I am at the point where I have ran out of possibilities?
link to editor:
page in question: admChkContent
Put in remarks for Wix where it goes wrong.
Sounds like a jsw function. (File with jsw extension).
Jsw functions - web methods - always return a promise. The return value is turned to a promise. The reason is that backend access have to be async, and those becomes a promise.
So a function returning a Boolean turns into a function returning a promise of a boolean (Promise).
As for the logs - the function has to resolve to a value for the logs to work. Yee, we know, it is not great. We are on it.
Yoav, thank you for your answer. Have been struggling with async/await and promises over the last few days with Andreas. I am close to getting it working, but really, this is more luck than knowledge. And I don´t like that. I like to understand what I am doing. So just a simple question: could you recommend any articles/sites that explain well the communication between front- and back end in an asynchronous environment like Wix Code?
And also about async/await? Andreas and I have tried almost everything, but the only thing that works (a call to a non-backend function) is the .then syntax, as if the whole async/await instructions are ignored.
We´re obviously doing something horribly wrong. Instead of asking someone to fix my code, I would rather work it out myself, but I need some pointers.
Thanks in advance.
Hi,
The concepts of async/await and promises are integrated with wix code but are fully belong to javascript,
There is a lot of information about them online, if you have any specific question we will be happy to help you.