mardi 3 mars 2015

How to retrieve a 'Product' object with Parse.Query


I am using Parse to create a WebApp and I am trying to get an instance of an object Productwith this code:



getProduct: function() {
var productClass = Parse.Object.extend("Product");
var query = new Parse.Query(productClass);
var result = query.get(productId, {
success: function(object) {
console.log(object.get("productName"));
},
error: function(object, error) {
...
}
});
return result;
}


I get a:



result.get is not a function


Printing the object only, I realized that I do not get a Product, I get this in the console (Safari):



[Log] Object (views.js, line 269)
_rejected: false
_rejectedCallbacks: Array[0]
_resolved: true
_resolvedCallbacks: Array[0]
_result: Arguments[1]
__proto__: Object


I tried many ways, but I am not able to retrieve a Product object and its attributes. What am I doing wrong?





Aucun commentaire:

Enregistrer un commentaire