0
votes

I have installed parse-server-example and I have uploaded my cloud code. I have a function there but I got error response.success is no function.

Parse.Cloud.define("submitWeeklyScore", function (request, response) {
const gameScore = new Parse.Object("WeeklyGameScore");

gameScore.set("id", request.params.id);
gameScore.set("score", request.params.score);
gameScore.set("name", request.params.name);
gameScore.set("family", request.params.family);
gameScore.set("username", request.params.username);

gameScore.save(null, {useMasterKey: true}).then((saveResult) => {
    var playerScore = saveResult.get("score");
    var playerCreatedAt = saveResult.createdAt;
    var objectId = saveResult.id;
    var mainQuery = new Parse.Query("WeeklyGameScore");
    mainQuery.greaterThanOrEqualTo("score", playerScore);
    mainQuery.lessThan("createdAt", playerCreatedAt);

    mainQuery.count({useMasterKey: true}).then((count) => {
        var obj = {rank: count + 1, objId: objectId};
        response.success(obj);
    }, (error) => {
        response.error(error);
    });

}, (error) => {
    response.error(error);
});
});

if I replace response.success(obj); with return obj; I get this :

info: Ran cloud function submitWeeklyScore for user undefined with:
  Input: {"score":1337,"rubikaId":11111,"name":"","family":"","username":""}
  Result: undefined {"functionName":"submitWeeklyScore","params": {"score":1337,"rubikaId":11111,"name":"","family":"","username":""}}

The object would be save without any problem but there is no result.

1

1 Answers

2
votes

Parse Server example installs the latest version of parse server. Version 3.0.0 of Parse Server removed response.success(). Please see the migration guide for details on updating your cloud code.