Parse.com 失败:ReferenceError
Parse.com Failed with: ReferenceError
我正在尝试 运行 Cloud Code 中的以下解析后台作业
Parse.Cloud.job("sendAlert", function(sendAlert) {
Parse.Push.send({
data: {
"content-available": 1,
}
}, {
success: function() {
status.success("Push Worked!!!");
},
error: function(error) {
status.error("Uh oh, something went wrong.");
}
});
});
预期的结果是,当它是 运行 时,向用户发送 "transparent"(用户看不到,但应用程序看到)推送。
当我 运行 它时,我得到错误
Jobs:
sendAlert
E2015-02-20T19:17:22.637Z] v17: Ran job sendAlert with:
Input: {}
Failed with: ReferenceError: status is not defined
at Object.Parse.Push.send.error (main.js:12:5)
at Parse.js:2:7940
at f (Parse.js:2:6852)
at Parse.js:2:6344
at Array.forEach (native)
at Object.x.each.x.forEach [as _arrayEach] (Parse.js:1:661)
at c.extend.reject (Parse.js:2:6297)
at Parse.js:2:6956
at f (Parse.js:2:6852)
at Parse.js:2:7386
在日志中。我究竟做错了什么?谢谢,感谢 - 这里是 Parse 新手。
如果您在代码中查找单词 status
,您会发现您没有在任何地方声明它。一个名为 status
的变量不能凭空出现,所以这就是你得到 ReferenceError 的原因。
根据documentation,传入Parse.Cloud.job()
回调的第二个参数是一个JobStatus
对象,带有error
和success
方法,所以它似乎这就是您要使用的内容:
// declare it here ---------v
Parse.Cloud.job("sendAlert", function(sendAlert, status) {
Parse.Push.send({
data: {
"content-available": 1,
}
}, {
success: function() {
status.success("Push Worked!!!");
},
error: function(error) {
status.error("Uh oh, something went wrong.");
}
});
});
我正在尝试 运行 Cloud Code 中的以下解析后台作业
Parse.Cloud.job("sendAlert", function(sendAlert) {
Parse.Push.send({
data: {
"content-available": 1,
}
}, {
success: function() {
status.success("Push Worked!!!");
},
error: function(error) {
status.error("Uh oh, something went wrong.");
}
});
});
预期的结果是,当它是 运行 时,向用户发送 "transparent"(用户看不到,但应用程序看到)推送。
当我 运行 它时,我得到错误
Jobs: sendAlert E2015-02-20T19:17:22.637Z] v17: Ran job sendAlert with: Input: {} Failed with: ReferenceError: status is not defined at Object.Parse.Push.send.error (main.js:12:5) at Parse.js:2:7940 at f (Parse.js:2:6852) at Parse.js:2:6344 at Array.forEach (native) at Object.x.each.x.forEach [as _arrayEach] (Parse.js:1:661) at c.extend.reject (Parse.js:2:6297) at Parse.js:2:6956 at f (Parse.js:2:6852) at Parse.js:2:7386
在日志中。我究竟做错了什么?谢谢,感谢 - 这里是 Parse 新手。
如果您在代码中查找单词 status
,您会发现您没有在任何地方声明它。一个名为 status
的变量不能凭空出现,所以这就是你得到 ReferenceError 的原因。
根据documentation,传入Parse.Cloud.job()
回调的第二个参数是一个JobStatus
对象,带有error
和success
方法,所以它似乎这就是您要使用的内容:
// declare it here ---------v
Parse.Cloud.job("sendAlert", function(sendAlert, status) {
Parse.Push.send({
data: {
"content-available": 1,
}
}, {
success: function() {
status.success("Push Worked!!!");
},
error: function(error) {
status.error("Uh oh, something went wrong.");
}
});
});