In parse cloud code NodeJS. I create a new object using Parse.Object. But I cannot save it. I got an error like this: ParseError { code: 107, message: 'Received an error with invalid JSON from Parse: \n\n\n\nError\n\n\n
Cannot POST /classes/GameScore\n\n' }
In my /cloud/main.js. var Parse = require("parse/node")
Parse.Cloud.define("newGameScore", function (req, res) {
var GameScore = Parse.Object.extend("GameScore");
var gameScore = new GameScore();
gameScore.set("score", 1337);
gameScore.set("playerName", "Sean Plott");
gameScore.set("cheatMode", false);
gameScore.save({useMasterKey: true}, {
success: function (gameScore) {
// Execute any logic that should take place after the object is saved.
console.log("Awesome");
alert('New object created with objectId: ' + gameScore.id);
},
error: function (gameScore, error) {
console.log(error);
// Execute any logic that should take place if the save fails.
// error is a Parse.Error with an error code and message.
alert('Failed to create new object, with error code: ' + error.message);
}
});
})
via Louis
No comments:
Post a Comment