gpt4 book ai didi

javascript - parse.com 云代码问题,但在 javascript 中运行完美

转载 作者:行者123 更新时间:2023-11-30 17:41:45 26 4
gpt4 key购买 nike

我在这段不想工作的代码上浪费了 8 个小时

在 localhost 和 javascript 上它运行良好,但在 parse.com 云代码中我得到一个变量未定义。

Parse.Cloud.define("goGetPrices", function(request, response) {

var price;

function getPrices(stockPrice){
console.log(stockPrice);

var PriceTick = Parse.Object.extend("StockPrices");
var queryInstal = new Parse.Query(Parse.Installation);

var queryLess = new Parse.Query(PriceTick);
var queryMore = new Parse.Query(PriceTick);

queryLess.equalTo("Position","Less");
queryLess.greaterThan("Price", stockPrice);

console.log(PriceTick) // RETURNS UNDEFINED
console.log(queryInstal) // RETURNS UNDEFINED

因为那些返回未定义的代码的其余部分无法工作......奇怪的是这在没有云代码的本地主机上工作得很好

queryLess.find({
success: function(results) {
//Less than

console.log("found less");

if (results.length) {

for (var i = 0; i < results.length; i++) {
var object = results[i]

var devicetoken = object.get('devicetoken');
var objID = object.get('objectId');

console.log("Got Less");
queryInstal.equalTo('deviceToken', devicetoken);
queryInstal.equalTo('deviceType', 'ios');

Parse.Push.send({
where: queryInstal, // Set our Installation query
data: {
alert: "The price is now: "+stockPrice
}
}, {
success: function() {
// Push was successful
object.destroy({});


},
error: function(error) {
// Handle error
}
});
}
}},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});




Parse.Cloud.httpRequest({
url: "example.php",
dataType: 'json',
type: 'GET',
success: function(data) {
price = data.data.Response.price;
response.success("yes")
getPrices(price);

},
error: function(data) {
response.error('Request failed with response code ' + data.status);

}
}); });

最佳答案

你必须使用Parse.Query(ClassName),其中 ClassNameParse.Object 子类的名称字符串或实例:

https://parse.com/docs/js/symbols/Parse.Query.html

关于javascript - parse.com 云代码问题,但在 javascript 中运行完美,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20928598/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com