无法在nodeJS中保存Parse.Object

时间:2017-03-16 04:19:57

标签: javascript node.js parse-server

在解析云代码NodeJS中。我使用Parse.Object创建了一个新对象,但我无法保存它。我收到这样的错误:

ParseError {
  code: 107,
  message: 'Received an error with invalid JSON from Parse: <!DOCTYPE html>\n<html lang="en">\n<head>\n<meta charset="utf-8">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot POST /classes/GameScore</pre>\n</body>\n'
}

在我的 /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);
        }
    });
})

0 个答案:

没有答案