Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse cloud code strange error #535

Closed
martinappberg opened this issue Feb 20, 2016 · 2 comments
Closed

Parse cloud code strange error #535

martinappberg opened this issue Feb 20, 2016 · 2 comments

Comments

@martinappberg
Copy link

This cloud code function has been working perfectly until all of the sudden it gives me code: 141 error no reason and no description. It was working until I published a testflight and had two devices run the function after eachother. I run a ParseServer on Heroku with mongodb as database. I use masterkey and also have defined my server.

Parse.Cloud.define("ReadyUp", function(request, response) {
    Parse.Cloud.useMasterKey();
        var fbid = request.user.get("fbid");
        var query = new Parse.Query("Spel");
        query.equalTo("lobby", fbid);
        query.find().then(function(results) {
            results[0].addUnique("ready", fbid);
            return Parse.Object.saveAll(results);
        }).then(function(result) {
            response.success(result);
        }, function(error) {
            response.error(error);
        });
    });

This is the code to call the function from ios app:

    [PFCloud callFunctionInBackground:@"ReadyUp" withParameters:@{@"fbid":[[PFUser currentUser]objectForKey:@"fbid"]}
                                block:^(NSString *response, NSError *error) {
                                    if (!error) {
                                    }else {
                                        NSLog(@"%@",[error description]);
                                        [self fixParseBugsforUpdateWithLobby:nil];
                                    }
                                }];

Please, any ideas? I'm starting to rip out my hair...

@tanmays
Copy link

tanmays commented Feb 20, 2016

Parse.Cloud.useMasterKey(); is no longer supported. The correct way to use the master key would be:

Parse.Cloud.define("ReadyUp", function(request, response) {
        var fbid = request.user.get("fbid");
        var query = new Parse.Query("Spel");
        query.equalTo("lobby", fbid);
        query.find({useMasterKey:true}).then(function(results) {
            results[0].addUnique("ready", fbid);
            return Parse.Object.saveAll(results, {useMasterKey:true});
        }).then(function(result) {
            response.success(result);
        }, function(error) {
            response.error(error);
        });
    });

@gfosco
Copy link
Contributor

gfosco commented Feb 20, 2016

@tanmays is correct. Please re-open if you have any issues. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants