Parse.Cloud.play找不到函数

Parse.Cloud.play can't find function

本文关键字:函数 找不到 play Cloud Parse      更新时间:2023-09-26

我想我误解了。play()函数中的一些东西。我花了好几天想弄明白。

我在main.js中有一个函数的定义设置。

var pvp_module = require('cloud/otherCode.js');
function pushBattleMessage_sum(request, response)
{
    pvp_module.PushNotification_BattleMessageExport(request, response);
}
Parse.Cloud.define("PushNotification_BattleMessage", pushBattleMessage_sum);

这将它发送到运行该代码的另一个otherCode.js。在这段代码中,我需要调用第二个Cloud函数。

function PushNotification_BattleMessage(request, response)
{
    Parse.Cloud.run("push_httpRequest",{request},
    {
        sucess: function(results) 
        {
          response.success(results);
        },
        error: function(error) 
        {
          response.error(error);
        }
    });
}

第二个云函数在main.js中定义

Parse.Cloud.define('push_httpRequest',function(request)
{
  Parse.Cloud.httpRequest(
  {
    url: 'http://www.parse.com/',
    success: function(httpResponse) 
    {
      console.log(httpResponse.text);
    },
    error: function(httpResponse) 
    {
      console.error('Request failed with response code ' + httpResponse.status);
    }
  });
});

我在网上找到的一切都告诉我,这应该是工作的,但在我的testharness html中,我总是收到错误"Uncaught ReferenceError: push_httpRequest未定义"

这段代码的目的是Android要求推送通知图标必须是黑色和白色的。我无法用服务器端解析初始化该更改,因此我们通过httpRequest为GCM设备提供推送通知。如果我能让第一个Cloud函数找到第二个的话,我就能把所有这些都放到一起了

就我在文档中看到的,Parse.Cloud对象的define方法需要一个函数,该函数应该接受两个参数。那么你的函数push_httpRequest没有正确定义。来自Parse文档:

define( name, func )

定义一个云函数

仅在Cloud Code中可用。参数:

  • <String>名称云函数名称
  • 函数<Function>
    注册云函数。这个函数应该有两个参数Parse.Cloud.FunctionRequestParse.Cloud.FunctionResponse