Parse.com 代码不会部署:"Could not load triggers"
Parse.com code won't deploy: "Could not load triggers"
很有可能是我做错了,但我尝试合并the code at this page on GET requests with code to send pushes through background jobs, to create code that can fetch the price of a bitcoin,如果抓取成功,则作为推送发送。这是我的代码:
var query = new Parse.Query(Parse.Installation);
Parse.Cloud.job("sendAlert", function(sendAlert, status) {
Parse.Cloud.httpRequest({
url: 'https://api.bitcoinaverage.com/ticker/global/USD/last',
success: function(httpResponse) {
console.log(httpResponse.text);
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: (httpResponse.text)
}
}, {
success: function() {
status.success("Push Worked!!!");
},
error: function(error) {
status.error("Uh oh, something went wrong.")
}
});
},
error: function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
}
});
注意:我似乎无法弄清楚如何在上面的块中正确设置格式 - 这是它在我的编辑器中的照片。
该代码的预期功能是从 this site 中提取 1 BTC 的美元价格,并将其作为推送通知发送。
我确信我已经彻底破坏了一些东西,但我的代码无法部署,出现错误
Update failed with Could not load triggers. The error was Uncaught You must specify a key using Parse.initialize.
。那么,我该如何解决才能从明文 API 中获取数据并将其作为推送发送?或者有更好的方法吗?谢谢!!!
您需要在最开始指定一个key:
Parse.initialize("APPLICATION ID", "JAVASCRIPT KEY");
很有可能是我做错了,但我尝试合并the code at this page on GET requests with code to send pushes through background jobs, to create code that can fetch the price of a bitcoin,如果抓取成功,则作为推送发送。这是我的代码:
var query = new Parse.Query(Parse.Installation);
Parse.Cloud.job("sendAlert", function(sendAlert, status) {
Parse.Cloud.httpRequest({
url: 'https://api.bitcoinaverage.com/ticker/global/USD/last',
success: function(httpResponse) {
console.log(httpResponse.text);
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: (httpResponse.text)
}
}, {
success: function() {
status.success("Push Worked!!!");
},
error: function(error) {
status.error("Uh oh, something went wrong.")
}
});
},
error: function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
}
});
注意:我似乎无法弄清楚如何在上面的块中正确设置格式 - 这是它在我的编辑器中的照片。
该代码的预期功能是从 this site 中提取 1 BTC 的美元价格,并将其作为推送通知发送。
我确信我已经彻底破坏了一些东西,但我的代码无法部署,出现错误
Update failed with Could not load triggers. The error was Uncaught You must specify a key using Parse.initialize.
。那么,我该如何解决才能从明文 API 中获取数据并将其作为推送发送?或者有更好的方法吗?谢谢!!!
您需要在最开始指定一个key:
Parse.initialize("APPLICATION ID", "JAVASCRIPT KEY");