Hi Tapuat,
Actually, you should return promise from your service method
return Backendless.Persistence.of(Quote).find(dataQuery).then(function(){ /*something that should be run on succeed*/ }, function() {/*error handling*/});
For enabling promises, you should write the next code at the beginning of service description
Hi,
You don’t have to implement promises.
All that you need is call method Backendless.enablePromises().
It switches all API methods to the async mode and they all will return a promise as result of calling.
For example look at the method ‘find’.
It has two signature of calling
The synchronous call which returns a result of retrieving
var results = Backendless.Persistence.of(Quote).find(dataQuery);
The asynchronous call which throws a result of retrieving to the callback
Backendless.Persistence.of(Quote).find(dataQuery, new Backendless.Async(function(results) {}, function(error){}));
But if we call Backendless.enablePromises() in the beginning of the program the method ‘find’ will have only one signature of calling. It returns a promise which will be fulfilled by the results of retrieving
Backendless.enablePromises(); //it should be called once in the beginning of the program
//....
return Backendless.Persistence.of(Quote).find(dataQuery).then(function(results) {}, function(error){});