我的 afterSave 云代码应该在每次保存后运行,但我没有看到它执行任务。也没有调试信息写入本地“temp.txt”文件
我的解析服务器在 docker 容器上运行(可能是相关的) 在/parse-server/cloud子文件夹中创建 main.js 之后,我做了一个干净的 docker run(启动解析服务器),但仍然没有看到任何东西
我该如何调试这个云代码问题?
我的 main.js 内容:
Parse.Cloud.afterSave("Post", (request) => {
var fs = require("fs");
const image = request.object.get("image").url();
const detail = request.object.get("detail");
const geo = request.object.get("geo");
const itemId = request.object.get("objectId");
fs.writeFileSync('./temp.txt', request, function(err, data) {
if (err) console.log(err);
});
console.log(detail);
console.log(image);
console.log(geo);
console.log('========');
var data =detail+" "+image+" "+geo+" "+request;
fs.appendFileSync("./temp.txt", data, function(err, data) {
if (err) console.log(err);
console.log("Successfully Written to File.");
});
var postRequest = require('request');
postRequest({
method: 'POST',
preambleCRLF: true,
postambleCRLF: true,
json: true,
uri: 'https://graph.facebook.com/1111/feed?access_token=sometoken',
body:
{
message: detail,
link: image
}
},
function (error, response, body) {
if (error) {
return console.error('upload failed:', error);
console.log('statusCode:', response && response.statusCode);
fs.appendFileSync("temp.txt", response+" "+ response.statusCode
,function(err, data) {
if (err) console.log(err);
});
}
console.log('Upload successful! Server responded with:', body);
})
}
);