我正在使用masterkey但在尝试保存对象时仍然会收到未经授权的错误。任何人都可以找出原因吗?我可以看到"开始制作门票"得到记录。而request.params都提取正确的信息。
另外,一个附带问题......我的印象是,如果执行response.error,它会停止代码,但之后会将该错误消息发送到调用此云代码的函数,然后在那里运行任何错误处理。我在此云代码中有一个console.log错误消息,然后在调用它的函数中出现错误警报。我正在显示控制台日志,但不是警报。我的假设是错误的,因为它没有被传递,并且它实际上只是在执行response.error时终止整个事情?
Parse.Cloud.define("createRecord", function(request, response) {
var caseClass = Parse.Object.extend("Cases");
var ticket = new caseClass();
console.log("started making ticket");
ticket.title = request.params.title;
ticket.category = request.params.category;
ticket.priority = request.params.priority;
ticket.description = request.params.cmnts;
ticket.save(null, {useMasterKey: true}).then(function() {
response.success();
}, function(error) {
response.error("error response: " + error.message);
});
答案 0 :(得分:0)
试试这个:
Parse.Cloud.run("createRecord", {something: yourData}, {...
和
Parse.Cloud.define("createRecord", function (request, response) {
var something = request.params.something;
var caseClass = Parse.Object.extend("Cases");
var ticket = new caseClass();
console.log("started making ticket");
ticket.set("title", something.title);
ticket.set("category", something.category);
ticket.set("priority", something.priority);
ticket.set("description", something.cmnts);
ticket.save(null, {useMasterKey: true}).then(function() {
response.success();
}, function(error) {
response.error("error response: " + error.message);
});