未捕获语法:输入意外结束 likedc.js:0
Uncaught Syntax: Unexpected end of input likedc.js:0
我尝试在缺少的输入上添加 { 或 ) 的几次尝试。我问了不同的问题,因为我错过了逗号和括号,而且缩进方式不对。我找不到此代码中缺少的 { 或 ) 是什么。
Parse.Cloud.afterSave("StatusUpdate", function(request) {
if(request.object.existed()) {
return;
}
// if the user is Undefined
var toUser = request.object.get("user") ---< **** Line 8 ****
if (!toUser)
{
throw "Undefined toUser. Skipping push for Activity " + request.object.get('StatusUpdate') + " : " + request.object.id;
return;
}
// put Installation query here if needed
// send notifications based on the StatusUpdate and the passed in user from iOS ---< **** Line 16 ****
Parse.Cloud.useMasterKey() // depreciated in self hosted parse servers
// create query based on passed in values
Parse.Cloud.define("StatusUpdate", function(request, response) {
//query Installation for user
var Installationquery = Parse.Object.extend("Installation");
var query = new Parse.Query(Installationquery);
var message = request.params.message
query.equalTo("user", request.params.User);
query.find({
success: function(results) {
response.success("found user" + results)
// Do something with the returned Parse.Object values
for (var i = 0; i < results.length; i++) {
var object = results[i];
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: createMessage(message),
badge: "Increment",
sound: ""
}
}, {
success: function() {
// Push was successful
console.log("sent ")
},
error: function(error) {
console.log("Error " + error)
}
});
}
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
});
//})
var alertMessage = function createMessage(request) {
var message = "";
if (request.object.get("StatusUpdate") === "likedby") {
if (request.user.get('postedby')) {
message = request.user.get('postedby') + ': ' + request.object.get('statusOBJID').trim();
} else {
message = "Someone liked on your status update.";
}
// Trim our message to 140 characters.
if (message.length > 140) {
message = message.substring(0, 140);
}
return message;
}
}
您的代码存在的问题:
- 第 1 行:不匹配的“{”。
- 第 7 行:缺少分号。
- 第 18 行:缺少分号。
- 第 26 行:缺少分号。
- 第 30 行:缺少分号。
- 第 45 行:缺少分号。
- 第 48 行:缺少分号。
- 第 76 行:缺少分号。
- 第 76 行:应为 ')' 而看到的却是 ''。
- 第 76 行:缺少分号。
固定:
Parse.Cloud.afterSave("StatusUpdate", function(request) {
if(request.object.existed()) {
return;
}
});
// if the user is Undefined
var toUser = request.object.get("user");
if (!toUser)
{
throw "Undefined toUser. Skipping push for Activity " + request.object.get('StatusUpdate') + " : " + request.object.id;
return;
}
// put Installation query here if needed
// send notifications based on the StatusUpdate and the passed in user from ios
Parse.Cloud.useMasterKey(); // depreciated in self hosted parse servers
// create query based on passed in values
Parse.Cloud.define("StatusUpdate", function(request, response) {
//query Installation for user
var Installationquery = Parse.Object.extend("Installation");
var query = new Parse.Query(Installationquery);
var message = request.params.message;
query.equalTo("user", request.params.User);
query.find({
success: function(results) {
response.success("found user" + results);
// Do something with the returned Parse.Object values
for (var i = 0; i < results.length; i++) {
var object = results[i];
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: createMessage(message),
badge: "Increment",
sound: ""
}
}, {
success: function() {
// Push was successful
console.log("sent ");
},
error: function(error) {
console.log("Error " + error);
}
});
}
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
});
//})
var alertMessage = function createMessage(request) {
var message = "";
if (request.object.get("StatusUpdate") === "likedby") {
if (request.user.get('postedby')) {
message = request.user.get('postedby') + ': ' + request.object.get('statusOBJID').trim();
} else {
message = "Someone liked on your status update.";
}
// Trim our message to 140 characters.
if (message.length > 140) {
message = message.substring(0, 140);
}
return message;
}
};
我尝试在缺少的输入上添加 { 或 ) 的几次尝试。我问了不同的问题,因为我错过了逗号和括号,而且缩进方式不对。我找不到此代码中缺少的 { 或 ) 是什么。
Parse.Cloud.afterSave("StatusUpdate", function(request) {
if(request.object.existed()) {
return;
}
// if the user is Undefined
var toUser = request.object.get("user") ---< **** Line 8 ****
if (!toUser)
{
throw "Undefined toUser. Skipping push for Activity " + request.object.get('StatusUpdate') + " : " + request.object.id;
return;
}
// put Installation query here if needed
// send notifications based on the StatusUpdate and the passed in user from iOS ---< **** Line 16 ****
Parse.Cloud.useMasterKey() // depreciated in self hosted parse servers
// create query based on passed in values
Parse.Cloud.define("StatusUpdate", function(request, response) {
//query Installation for user
var Installationquery = Parse.Object.extend("Installation");
var query = new Parse.Query(Installationquery);
var message = request.params.message
query.equalTo("user", request.params.User);
query.find({
success: function(results) {
response.success("found user" + results)
// Do something with the returned Parse.Object values
for (var i = 0; i < results.length; i++) {
var object = results[i];
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: createMessage(message),
badge: "Increment",
sound: ""
}
}, {
success: function() {
// Push was successful
console.log("sent ")
},
error: function(error) {
console.log("Error " + error)
}
});
}
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
});
//})
var alertMessage = function createMessage(request) {
var message = "";
if (request.object.get("StatusUpdate") === "likedby") {
if (request.user.get('postedby')) {
message = request.user.get('postedby') + ': ' + request.object.get('statusOBJID').trim();
} else {
message = "Someone liked on your status update.";
}
// Trim our message to 140 characters.
if (message.length > 140) {
message = message.substring(0, 140);
}
return message;
}
}
您的代码存在的问题:
- 第 1 行:不匹配的“{”。
- 第 7 行:缺少分号。
- 第 18 行:缺少分号。
- 第 26 行:缺少分号。
- 第 30 行:缺少分号。
- 第 45 行:缺少分号。
- 第 48 行:缺少分号。
- 第 76 行:缺少分号。
- 第 76 行:应为 ')' 而看到的却是 ''。
- 第 76 行:缺少分号。
固定:
Parse.Cloud.afterSave("StatusUpdate", function(request) {
if(request.object.existed()) {
return;
}
});
// if the user is Undefined
var toUser = request.object.get("user");
if (!toUser)
{
throw "Undefined toUser. Skipping push for Activity " + request.object.get('StatusUpdate') + " : " + request.object.id;
return;
}
// put Installation query here if needed
// send notifications based on the StatusUpdate and the passed in user from ios
Parse.Cloud.useMasterKey(); // depreciated in self hosted parse servers
// create query based on passed in values
Parse.Cloud.define("StatusUpdate", function(request, response) {
//query Installation for user
var Installationquery = Parse.Object.extend("Installation");
var query = new Parse.Query(Installationquery);
var message = request.params.message;
query.equalTo("user", request.params.User);
query.find({
success: function(results) {
response.success("found user" + results);
// Do something with the returned Parse.Object values
for (var i = 0; i < results.length; i++) {
var object = results[i];
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: createMessage(message),
badge: "Increment",
sound: ""
}
}, {
success: function() {
// Push was successful
console.log("sent ");
},
error: function(error) {
console.log("Error " + error);
}
});
}
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
});
//})
var alertMessage = function createMessage(request) {
var message = "";
if (request.object.get("StatusUpdate") === "likedby") {
if (request.user.get('postedby')) {
message = request.user.get('postedby') + ': ' + request.object.get('statusOBJID').trim();
} else {
message = "Someone liked on your status update.";
}
// Trim our message to 140 characters.
if (message.length > 140) {
message = message.substring(0, 140);
}
return message;
}
};