从另一个云函数中获取响应

时间:2022-05-20 16:01:56

I have in my cloud code this two functions What I'm trying to do is calling one function from another one (hello from count). The problem is the success block in the run function isn't executed and the console remain silent. What to do ?

我在我的云代码中有这两个函数我正在尝试做的是从另一个函数调用一个函数(hello from count)。问题是运行功能中的成功块未执行且控制台保持静默。该怎么办 ?

Count Function :

计数功能:

Parse.Cloud.define('count', function(request, response) {

var query = new Parse.Query('MyClass');
  query.find({
    success: function(results) {

      Parse.Cloud.run('hello', {}, {
       success: function(result) {
         console.log('What is the result ? ' + result);
       },
       error: function(error) {
       }
       });
      response.success(results);
    },
    error: function(error) {
      response.error(error);
    }
  });
});

Hello Function :

你好功能:

Parse.Cloud.define('hello', function(request, response) {
 response.success("Hello world!");
});

1 个解决方案

#1


0  

This is because your hello function is executed asynchronously but before it finishes, your code already has hit response.success(results);. You either need to move the response.success(); to your hello success block or you need to use Promises.

这是因为你的hello函数是异步执行的,但在它完成之前,你的代码已经命中了response.success(results);.您需要移动response.success();你的hello成功块或你需要使用Promises。

#1


0  

This is because your hello function is executed asynchronously but before it finishes, your code already has hit response.success(results);. You either need to move the response.success(); to your hello success block or you need to use Promises.

这是因为你的hello函数是异步执行的,但在它完成之前,你的代码已经命中了response.success(results);.您需要移动response.success();你的hello成功块或你需要使用Promises。