I have been trying to migrate my Cloud functions from Parse Server 2.8.4 to 3.0+.
This following Cloud function aims to return count of GCUR_OBSERVATION to the client. I intended to use native promises in synchronous instead of async/await.
Parse.Cloud.define("countOfObservations", (request) => {
var query = new Parse.Query("GCUR_OBSERVATION");
var countOfObs = 0;
query.count({ useMasterKey: true }).then( (count) => {
countOfObs = count;
console.log("*** count=" + countOfObs);
return countOfObs;
});
});
When I tried call this function from cURL:
curl -X POST -H "X-Parse-Application-Id: {APP_ID}" -H "X-Parse-REST-API-Key: {REST_API_KEY}t" -H "Content-Type: application/json" https://{SERVER_URL}/parse/functions/countOfObservations
{}
was returned. However the back-end console printed *** count=2882
.
Is there anything I did wrong?