使用命令行将Parse Cloud Code更新为以下内容。出于某种原因获取此错误。获取未捕获的语法错误:第4行意外的ILLEGAL。命令行表示已完成上传文件,但是,此错误将立即打印在下方,并且不会更新解析云代码。
// Use Parse.Cloud.define to define as many cloud functions as you want.
// For example:
Parse.Cloud.define("hello", function(request, response) {
response.success(“Hello, PARSE Cloud coming back”);
});
var express = require("express"),
app = express(),
crypto = require('crypto'),
buffer = require('buffer'),
url = require('url');
var config = new Parse.Object("Config");
config.set("client_id", "");
config.set("client_secret", "");
config.set("callback_url", "");
config.set("endpoint", "");
var AUTH_HEADER = "Basic " + new buffer.Buffer(config.get("client_id") + ":" + config.get("client_secret")).toString("base64");
app.use(express.bodyParser());
Parse.Cloud.define("swap", function (req, res) {
if (!req.body || !req.body.hasOwnProperty("code")) {
res.status(550).send("Permission Denied");
return;
}
var form_data = {
"grant_type": "authorization_code",
"redirect_uri": config.get("callback_url"),
"code": req.body.code
};
Parse.Cloud.httpRequest({
method: "POST",
url: url.resolve(config.get("endpoint"), "/api/token"),
headers: {
"Authorization": AUTH_HEADER,
"Content-Type": "application/x-www-form-urlencoded"
},
body: form_data,
success: function(httpResponse) {
if (httpResponse.status != 200) {
res.status(550).send("Permission Denied");
return;
}
var token_data = JSON.parse(httpResponse.text);
res.status(200).set({
"Content-Type": "application/json"
}).send(token_data);
},
error: function(httpResponse) {
res.status(500).send("Internal Server Error");
return;
}
});
});
答案 0 :(得分:1)
您正在使用奇怪的引号字符。
答案 1 :(得分:1)
第二行中的引号不是有效的标记,因此编译器无法理解它们:
Parse.Cloud.define("hello", function(request, response) {
response.success(“Hello, PARSE Cloud coming back”); //Those quotes.
});
使用正常“
更改"
,您就可以了!