我有一个parse.com数据库,我使用objectID查询。它返回数据,但我只能在promise对象中看到它作为属性,我无法从文档中弄清楚它是如何工作的,我应该如何实际获取数据并将其转换为对象而不是Promise 。如果我之后调用该函数或将其保存为变量或成功函数中的某些内容,我是否需要在之前的某处定义评论?任何一个例子都很棒
var query = new Parse.Query("business_and_reviews");
var results = new Parse.Object("business_and_reviews");
query.get("pLaARFh2gD", {
success: function(results) {
// results is an array of Parse.Object.
},
error: function(object, error) {
// The object was not retrieved successfully.
// error is a Parse.Error with an error code and message.
}
});
var name = results.get("city");
console.log(name);
这是chrome中的Promise
答案 0 :(得分:1)
get()只返回一个带id的对象。
var query = new Parse.Query("business_and_reviews");
query.get("pLaARFh2gD", {
success: function(result) {
var name = result.get("city");
console.log(name);
}
});
以下是document的另一个例子。
var GameScore = Parse.Object.extend("GameScore");
var query = new Parse.Query(GameScore);
query.get("xWMyZ4YEGZ", {
success: function(gameScore) {
var score = gameScore.get("score");
var playerName = gameScore.get("playerName");
var cheatMode = gameScore.get("cheatMode");
},
error: function(object, error) {
// The object was not retrieved successfully.
// error is a Parse.Error with an error code and message.
}
});
答案 1 :(得分:0)
谢谢,我现在解决了,首先必须在成功的内部:函数,然后必须选择对象中的信息,如下所示:
5f