我在执行函数时遇到了一些问题,因为我不断收到有关未提供我的 masterKey 的相同错误:
[PFCloud callFunctionInBackground:@"changeUserModeratorStatus" withParameters:@{@"objectId": self.objId}];
函数:
Parse.Cloud.define("changeUserModeratorStatus", function(request, response) {
Parse.Cloud.useMasterKey();
var query = new Parse.Query(Parse.User);
query.equalTo("objectId", request.params.objectId);
query.first({
success: function(anotherUser) {
anotherUser.set("ModeratorStatus", "Approved");
anotherUser.save(null, {
success: function(anotherUser) {
response.success("Successfully updated user.");
},
error: function(failedRetrieve, error) {
response.error("Could not save changes to user.");
}
});
},
error: function(error) {
response.error("Could not find user.");
}
});
});
编辑,我从字面上复制/粘贴了论坛上的 Hectors 示例,检查了文档但没有找到解决方案。无论我做什么,我都会收到错误消息:无法使用主 key ,尚未提供
最佳答案
您可能在云代码的初始化中缺少主 key -
Parse.initialize(applicationId, javaScriptKey, masterKey).
取出整个初始化解决了我的问题,因为 Parse
实际上使用您的 application id
、JavaScript key
和 master key
所以你不必这样做。
关于javascript - Parse Cloud Code功能 不能使用Master Key,没有提供,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32020762/