如何在 Parse.com CloudCode 上创建自定义帮助程序模块以与 then() promise 一起使用?类

how to create a custom helper module on Parse.com CloudCode for using with then() promise? TypeError: Cannot call method 'then' of undefined

本文关键字:then promise 一起 模块 com Parse CloudCode 帮助程序 自定义 创建      更新时间:2023-09-26

我是 Parse.com CloudCode和Node的新手.js

正在尝试找到一种方法来创建帮助程序模块,其中包含一些查询和其他常见代码,我可能需要在我的应用程序中一遍又一遍地使用。

如何使用不同步的帮助程序方法创建模块?

我怎样才能让它与承诺一起工作? http://blog.parse.com/2013/01/29/whats-so-great-about-javascript-promises/

这是我的意图。我不确定正确的方法是什么

我收到此错误:类型错误:无法调用未定义的方法"then"

exports.getMyObjects = function (myParam, status) {
var MyObject = Parse.Object.extend("MyObject");
var query = new Parse.Query(MyObject);
query.get(myParam).then(function(myObjects){
status.success(myObjects);
},function(error){
 status.error(error);
});
};

//Here on another file I'm trying to use the module
var helper = require('cloud/helper.js');
helper.getMyObjects('sdfsd43').then(function(myObjects){
 //Objects found!
},function(error){
//Error
});
// I'm getting thes error from parse: TypeError: Cannot call method 'then' of undefined

我遇到了类似的问题,并且能够通过更改global.json中的解析版本来修复它

"全局":{

"parseVersion": "1.2.7"

}