我正在尝试将我新编写的云代码功能部署到Parse,但是在第110行我不断收到错误“意外标识符”,我似乎无法弄清楚这里有什么错误,有什么帮助吗?

Parse.Cloud.define("backgroundJob", function(request, response) {
Parse.Cloud.useMasterKey();

var moments = require("cloud/moments.js");

var now = moments.moment();
var groupObject = Parse.Object.extend("Group");
var query = new Parse.Query(groupObject);

var eventObject = Parse.Object.extend("Event");

query.find().then(function(groups) {
    var promise = Parse.Promise.as();
    _.each(group, function(result) {
        promise = promise.then(function() {
            var count = 0;
            var events = _.map(result.get("Events"), function(eventArray) {
                if (now == eventArray[count].get('date') {

                var curEvent = eventArray[count];
                eventArray[count].destory();

                var relationc = result.get("created");

                var createdq = relationc.query();

                var relationj = result.get("created");

                var joinedq = relationj.query();

                var partOnee = curEvent.get("name");
                var outString = partOnee.concat(" is now");

                Parse.Push.send({
                    where: createdq,
                    data: {
                        alert: outString
                    }
                }).then(function() {
                    response.success();
                }, function(error) {
                    response.error(error);
                });

                Parse.Push.send({
                    where: joinedq,
                    data: {
                        alert: outString
                    }
                }).then(function() {
                    response.success();
                }, function(error) {
                    response.error(error);
                });

                }

                count = count+1;
            });

        });
    });
}).then(function() {
    response.success()
}, function(error) {
    response.error(error);
});
});


第110行是var curEvent = eventArray [count];

最佳答案

您在)这一行中错过了if (now == eventArray[count].get('date'),请参阅:

        var events = _.map(result.get("Events"), function(eventArray) {
            if (now == eventArray[count].get('date') {


固定:

        var events = _.map(result.get("Events"), function(eventArray) {
            if (now == eventArray[count].get('date')) {


请注意,当解释器/编译器(使用大多数编程语言)说在线上存在问题时,通常该问题可以在之前的任何行中出现。

关于javascript - 在我的云代码中解析“main.js中的意外标识符”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33457480/

10-13 00:57