Search code examples
javascriptparse-platformparse-cloud-code

Error: Parse Objects not allowed here


When I try to run count function I get

Error: Parse Objects not allowed here

E2015-11-09T12:36:10.778Z]v184 Ran cloud function count with:
  Input: {}
  Result: Error: Parse Objects not allowed here
    at n (Parse.js:16:1063)
    at Parse.js:16:1927
    at Array.map (native)
    at n (Parse.js:16:1904)
    at n (Parse.js:16:1995)
    at r.default (Parse.js:16:2422)
    at Object.o.default.setCloudController.run (Parse.js:13:2159)
    at Object.n [as run] (Parse.js:13:1730)
    at e.query.find.success (main.js:10:19)
    at e.<anonymous> (Parse.js:14:28224)

The searching result guide me to this question, But All the tutorials mention sending parameters in this way. And this code used to be functioning well.

Count Function :

Parse.Cloud.define('count', function(request, response) {

var query = new Parse.Query('MyS');
  query.equalTo("Notify", true);
  query.notEqualTo ("MainEventCode", '5');

  query.find({
    success: function(results) {
      Parse.Cloud.run('http', {params : results}).then(
        function(result) {
          console.log('httpResponse is : ' + result);
          response.success('Done !');
        }, function(error) {
          console.log('Error while RUN !' + error);
      });
    },
    error: function(error) {
      response.error(error);
    }
  });
});

http Function :

Parse.Cloud.define('http', function(request, response) {

var query = new Parse.Query(Parse.Installation);
.
.
.
}

Solution

  • I'm assuming results is an array of PFObjects. Unfortunately you can not send PFObjects or an array containing PFObjects as parameters. Instead you'll need to send an array of their object Ids, and retrieve the actual objects in your http function.