【问题标题】:Parse server response "Unexpected token"解析服务器响应“意外令牌”
【发布时间】:2016-08-20 19:18:06
【问题描述】:

我正在努力在 Heroku 上安装 Parse Server。我正在使用这个应用程序:

https://github.com/ParsePlatform/parse-server-example

使用本指南上传到 heroku:

https://devcenter.heroku.com/articles/getting-started-with-nodejs

我已经更新了解析服务器代码中的数据库和服务器 URL,并且一切都正确上传和部署。但是,当我尝试按照本指南中的说明使用 cURL 测试服务器时:

https://github.com/ParsePlatform/parse-server

我收到以下错误:

{"error":"Unexpected token '"}

我已经复制并粘贴了 cURL 命令,并针对我的 url 进行了修改:

curl -X POST -H "X-Parse-Application-Id: myAppId" -H "Content-Type: application/json" -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' http://my-app-name.herokuapp.com/parse/classes/GameScore

Heroku 日志显示请求进入(所以我知道它会到达正确的位置)但没有错误。如果这很重要,我正在从 Windows 7 进行部署。这是我第一次使用 heroku 和解析服务器,所以我有点盲目。有人看到问题了吗?

【问题讨论】:

  • 同样的问题,有消息了吗?
  • 我已经以其他方式验证了我的应用程序,但尝试在 Json 中转义双引号。我认为反斜杠逃脱了。让我知道它是否有效。
  • 刚才看到的一样。我也发布了我自己的问题。这个问题解决了吗?
  • 我想我从来没有弄清楚为什么 cURL 不起作用。

标签: heroku parse-platform parse-server


【解决方案1】:

尝试将您的 POST 数据字段的简单引号反转为双引号,这对我有用:

#here : "{'score':1337,'playerName':'Sean Plott','cheatMode':false}"

curl -X POST -H "X-Parse-Application-Id: myAppId" -H "Content-Type: application/json" -d "{'score':1337,'playerName':'Sean Plott','cheatMode':false}" http://my-app-name.herokuapp.com/parse/classes/GameScore

改为

#here : '{"score":1337,"playerName":"Sean Plott","cheatMode":false}'
curl -X POST -H "X-Parse-Application-Id: myAppId" -H "Content-Type: application/json" -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' http://my-app-name.herokuapp.com/parse/classes/GameScore

【讨论】:

  • 谢谢,我试试看。
  • 不幸的是,这没有任何效果 - 我得到了完全相同的错误。
【解决方案2】:

我遇到了这个问题 - 对我来说,解决方法是我使用了 Parse-Server 中不再需要的 restApi 密钥。

这也影响了我的 s3 适配器 - 不允许我通过仪表板上传任何图像。

我删除了 restApi 密钥,一切都开始工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-13
    • 2022-01-02
    • 2011-11-19
    • 2019-06-20
    • 2020-06-01
    相关资源
    最近更新 更多