解析+ Heroku查询500错误 [英] Parse + Heroku Query 500 Error

查看:151
本文介绍了解析+ Heroku查询500错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Parse的CLI和新的Heroku集成来创建脚手架NodeJS项目( parse new )。

它给你的示例云功能是:

  // Hello 
Parse.Cloud.define('hello' ,函数(request,response){

response.success('Hello world!'+(request.params.a + request.params.b));

} );

我可以用下面的CURL命令来打这条路线,一切都正常:

  curl -X POST \ 
-HX-Parse-Application-Id:b8qPYS4SLSz0WoSWXlWeQosmF2jJPUPydetg3esR\
-H X-Parse-REST-API-Key:TOJLbfbNXSQcBdDVnU0MnKVu7SyamQvZmorHL5iD\
-HContent-Type:application / json\
-d'{a:Adventurous,b :Parser}'\
https://api.parse.com/1/functions/hello

但是我添加了一个新的类到我的分析数据中,插入一行,并试图查询&返回结果。我不断收到 {code:143,error:无效webhook响应状态:500内部服务器错误} 作为响应。



我相当肯定这不是我的代码,而是猜测有一些配置步骤或我错过了什么。



这是我修改过的Parse函数:

  // Hello 
Parse.Cloud .define('hello',function(request,response){
var query = Parse.Query(Favorites);

query.find({useMasterKey:true})。 (
function(results){
response.success('win');
},function(){
response.error('fail');
});

});

以及插入行的我的Parse Class的图片:





我已经Google错误,找不到任何好的答案,只有措辞不佳的问题。我在这里完全不知所措。感谢您的帮助。

解决方案

看起来Parse在register-webhooks.js上初始化时发生错误post部署脚本:
Parse.initialize(process.env.PARSE_APP_ID,unused,process.env.PARSE_MASTER_KEY);

如果没有第二个参数(JavaScript键),则不能执行任何Parse.Query从云功能。



所以我的解决方案是:

$ ol

  • 在Heroku配置变量中添加新的 PARSE_JS_KEY (值为Parse-> Settings-> Keys中的JavaScript Key)




  • Parse.initialize(process.env.PARSE_APP_ID,process.env.PARSE_JS_KEY ,process.env.PARSE_MASTER_KEY);




    require ('./cloud/main.js');



    PS:Place process.env.PARSE_JS_KEY 直接在register-webhooks.js初始化器中不起作用。


    I used Parse's CLI with the new Heroku integration to create the scaffold NodeJS project (parse new).

    The example cloud function it gives you is:

    // Hello
    Parse.Cloud.define('hello', function(request, response) {    
    
      response.success('Hello world! ' + (request.params.a + request.params.b));
    
    });
    

    I can hit this route with the following CURL command and everything works fine:

    curl -X POST \
     -H "X-Parse-Application-Id: b8qPYS4SLSz0WoSWXlWeQosmF2jJPUPydetg3esR" \
     -H "X-Parse-REST-API-Key: TOJLbfbNXSQcBdDVnU0MnKVu7SyamQvZmorHL5iD" \
     -H "Content-Type: application/json" \
     -d '{"a": "Adventurous ", "b": "Parser"}' \
     https://api.parse.com/1/functions/hello
    

    But then I added a new Class to my Parse Data, inserted a row, and tried to query & return the results. I keep getting {"code":143,"error":"Invalid webhook response status: 500 Internal Server Error"} as the response.

    I'm fairly certain it is not my code that is the problem and am guessing there is some configuration step or something I'm missing.

    Here is my modified Parse function:

    // Hello
    Parse.Cloud.define('hello', function(request, response) {    
      var query = Parse.Query("Favorites");
    
      query.find({ useMasterKey: true }).then(
        function(results) {
          response.success('win');
        }, function() {
          response.error('fail');
        });
    
    });
    

    And a picture of my Parse Class with the inserted row:

    I have Googled the error and can't find any good answers only poorly worded questions. I'm completely at a loss here. Thanks in advance for your help.

    解决方案

    Looks like Parse is wrong initialised on register-webhooks.js post deploy script: Parse.initialize(process.env.PARSE_APP_ID, "unused", process.env.PARSE_MASTER_KEY);

    And without second parameter (JavaScript Key) you can't execute any Parse.Query from cloud functions.

    So my solution is:

    1. Add new PARSE_JS_KEY to Heroku Config Variables (value is JavaScript Key from Parse->Settings->Keys)

    2. In server.js file add line:

      Parse.initialize(process.env.PARSE_APP_ID, process.env.PARSE_JS_KEY, process.env.PARSE_MASTER_KEY);

    before require('./cloud/main.js');

    PS: Place process.env.PARSE_JS_KEY directly in register-webhooks.js initializer does not work.

    这篇关于解析+ Heroku查询500错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆