【问题标题】:How do I return a value from Parse Cloud Code to my iOS app?如何将 Parse Cloud Code 中的值返回到我的 iOS 应用程序?
【发布时间】:2016-05-01 22:03:13
【问题描述】:

试图了解我自托管 Parse 服务器上的云代码。

我正在尝试在 Swift 中调用我的云代码函数,向其传递一个参数,然后将其从云代码返回到我的应用程序以进行打印。 ISSUE:我不知道 Parse Cloud Code 上的代码返回发送给它的参数是什么样子的。我已经尝试过了,但没有运气......

Parse.Cloud.define('hello', function(req, res) {
    res.success(request.params['test']);
 });

这是我的 Swift 代码...

PFCloud.callFunctionInBackground("hello", withParameters: ["test":"tester"]) {
        (response: AnyObject?, error: NSError?) -> Void in
        if error == nil {
            let responseString = response as? String
            print(responseString)
        } else {
            print(error!.description)
        }
    }

有人可以帮我吗?使用上面的代码,我从print(error!.description) 收到此错误...

2016-05-01 17:51:32.031 TestApp[662:151287] [错误]: {"code":1,"message":"Internal server error."}(代码:1,版本:1.13。 0) 错误域=解析代码=1 "{"code":1,"message":"内部服务器错误。"}" UserInfo={error={"code":1,"message":"内部服务器错误。"} , NSLocalizedDescription={"code":1,"message":"内部服务器错误。"}, code=1}

【问题讨论】:

    标签: node.js parse-platform parse-cloud-code


    【解决方案1】:

    这看起来不像是 iOS 的问题,而是您的 Cloud Code 的问题。 “内部服务器错误”消息表明服务器存在问题。

    查看您发布的云代码,您引用了request.params['test'],但请求对象在您的函数参数中定义为req。将request.params['test'] 更改为req.params['test'],您应该一切顺利。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多