我正在努力在 Heroku 上放置一个解析服务器。我正在使用这个应用程序:
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 '"}
我已经复制并粘贴了针对我的 url 修改的 cURL 命令:
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 和解析服务器,所以我有点盲目。有人看到问题了吗?
最佳答案
尝试将 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
关于heroku - 解析服务器响应 "Unexpected token",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36873780/