Dear Backendless team,
I’m trying to build a custom event handler that would use the Backendless V6 transaction feature. I ran into a couple of problems.
Backendless Version (3.x / 5.x, Online / Managed / Pro )
6.0.4
Application ID
3B8C2D2E-B7D6-27F9-FF3F-ABEE20934E00
Description
The addRelation API seems not working. When I called unitOfWork.addRelation in event handler code, it keeps throwing missing ) after argument list error.
For some API that didn’t throw error, when the code is running in cloud, it will gives Backendless.UnitOfWork() is not a constructor error. I copied the exact same code from document. const unitOfWork = new Backendless.UnitOfWork();.
Make sure to change the name of the method to addToRelation. I think it is the culprit of the errors. I will make sure the docs are updated as well to reflect this.
missing ) after argument list error is a JS syntax error because you’re passing neither object nor the simple arguments list in the ‘addRelation’ method.
Thank you for your reply. You are right, the new function call doesn’t throw any error now when I run npm run debug.
However, it still causes the second problem as I described in the description at the beginning. When this event handler receives any requests, it throws TypeError: Backendless.UnitOfWork is not a constructor. I copied the exact same code as you posted here. Is there any problem with the way I initialize the unitOfWork instance?
Yes, I did that yesterday. I just did it again. I ran npm i and also npm i backendless-coderunner and now it’s version 5.5.0. Seems all packages are up-to-date. Yet the problem remains.