user2918201
user2918201

Reputation: 52

How to pass Parse.com Cloud Code parameters correctly?

I am calling a cloud code function with Parse js

Parse.Cloud.run('enterproductwithid', 
     { 
         "token": token,
         "objId": objectIdOfCurrentProd,
         "username": currentUser1.username
     }

And my cloud code function is:

Parse.Cloud.define("enterproductwithid", function(request, response) 
  {
     console.log(request.params);
  });

Only the token parameter is passed. Nothing else logs. Any thoughts so I can stop pulling my hair out?!

Thanks!!

Upvotes: 0

Views: 2200

Answers (1)

cgauss
cgauss

Reputation: 324

Do not put the parameter keys in quotes. It is similar to a $.ajax POST function.

Parse.Cloud.run('enterproductwithid', 
      {
        token: token, 
        objId: objectIdOfCurrentProd, 
        username: currentUser1.username
      },{
      success: function(result) {
          //do neat stuff
      }, 
      error: function(e) {
         //error
      }
});

Upvotes: 4

Related Questions