Javascript Parse JS SDK:无法使用主密钥,尚未提供主密钥

Javascript Parse JS SDK:无法使用主密钥,尚未提供主密钥,javascript,angular,parse-platform,Javascript,Angular,Parse Platform,我需要在angular2应用程序中使用masterKey,但我无法将其传递给初始化函数,也无法通过谷歌搜索出原因。 从package.json:“解析”:“~1.9.2” 初始化: import {Parse} from '~/node_modules/parse/dist/parse'; @Injectable() export class TFCloudService { constructor() { this.parse = Parse; Pa

我需要在angular2应用程序中使用masterKey,但我无法将其传递给
初始化
函数,也无法通过谷歌搜索出原因。 从
package.json
“解析”:“~1.9.2”

初始化:

import {Parse} from '~/node_modules/parse/dist/parse';

@Injectable()
export class TFCloudService {
    constructor() {
        this.parse = Parse;

        Parse.initialize(appConfig.parse.appId, null, appConfig.parse.masterKey);
        Parse.serverURL = appConfig.parse.clientServerUrl;
        Parse.liveQueryServerURL = appConfig.parse.liveQueryServerURL;
    }
}
错误源:

this.edittedUser.save(null, {useMasterKey: true})
.then((user) => {
    console.log(user);
});
错误文本:
错误:无法使用主密钥,主密钥尚未提供。


appConfig.parse.masterKey
工作正常,我也用硬编码键检查了该行,但得到了相同的结果。

实际上猜到了传递该键的正确方法:

Parse.initialize(appConfig.parse.appId);
Parse.masterKey = appConfig.parse.masterKey;

您不应该在有角度的应用程序中使用主密钥,因为您可以让每个人都使用它。任何需要使用主密钥的操作都应该在服务器端完成。这救了我的命,谢谢。两天的搜索。这实际上适用于浏览器SDK。nodejs版本需要正常初始化。我使用了此方法,它工作正常,但当我尝试保存Parse.File时,我收到错误“TypeError:无法使用该数据创建Parse.File”我想强调,在客户端应用程序中使用主密钥是一个主要的安全缺陷,你基本上是让你的管理员用户名/密码对你所有的用户数据,数据库等@肯伯斯