Ashwini Pandarkar
Ashwini Pandarkar

Reputation: 31

throw 'You must provide an appId and masterKey!';

I am migrating my application from parse and going through parse-migration guide.

I executed parse-server-example locally given on https://github.com/ParsePlatform/parse-server-example and it works fine but after that I tried to run parse-server from https://github.com/ParsePlatform/parse-server but that show error as

throw 'You must provide an appId and masterKey!'; 

on command prompt.

Added mongodb url and other keys in index.js and DataAdapter.js but I dont know where do I add values for master key and app Id.

Upvotes: 0

Views: 1222

Answers (2)

Simon Bengtsson
Simon Bengtsson

Reputation: 8151

You should never have to download parse-server manually from github. Most often that is handled by npm. The parse-server-example you mentioned already uses parse-server to get a basic app up and running. parse-server-example is a good starting point for building out your own application and you never have to "switch" to something else.

The error you are seeing is because you don't provide an appId and masterKey in the parse configuration. This is copied from parse-server-example and is what the config object should look like.

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'myAppId',
  masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
  serverURL: process.env.SERVER_URL || 'http://localhost:1337'  // Don't forget to change to https if needed
});

Parse Server is just another npm module so I recommend reading up on nodejs and npm before using it.

Upvotes: 0

Bardyl
Bardyl

Reputation: 231

I'm not sure this is the best solution, but try this in your prompt:

export API_KEY=foo
export MASTER_KEY=bar

(just replace foo and bar by your own keys of course.)
Then, npm start again and it will works fine.

Upvotes: -1

Related Questions