Index.js 文件连续给出 "JSON text did not start with array" 尽管被格式化为数组
Index.js file continuously gives "JSON text did not start with array" despite being formatted as an array
我有一个由 heroku 托管的解析服务器,它有一个用于配置的 index.js
文件。我想使用 Mailgun 来为用户提供重设密码的功能,并且我已经按照 this answer 设置了配置文件,如下所示:
var api = new ParseServer({
appName: 'App Name',
publicServerURL: 'https://<name>.herokuapp.com/parse',
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 $
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't$
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query s$
},
push: JSON.parse(process.env.SERVER_PUSH || "{}"),
verifyUserEmails: true, //causing errors
emailAdapter: { //causing errors
module: 'parse-server-simple-mailgun-adapter',
options: {
fromAddress: 'parse@example.com',
domain: '<domain>',
apiKey: '<key>',
}
}
});
不过,由于 verifyUserEmails
和 emailAdapter
,此代码不起作用。删除它们会删除 "JSON text did not start with array" 错误。将它们中的任何一个添加回去都会导致抛出错误。不过,我不知道为什么,因为我没有看到任何明显的原因说明它们没有正确地设置在数组中?
除了将它们放在配置文件中之外,我是否需要在 heroku 中设置相应的配置变量?我考虑过这个,但是appName
和publicServerURL
不是这样设置的,不要报这个错。
emailAdapter.options.apiKey 末尾不需要逗号,因为它的最后一个元素是 JSON.
当您不正确地包含 verifyUserEmails 时,如果您在末尾也留下逗号,我不会感到惊讶。
options: {
fromAddress: 'parse@example.com',
domain: '<domain>',
apiKey: '<key>',
}
这是无效的 JSON,因为 apiKey 行末尾有一个逗号。 JSON 对象中的最后一项没有逗号。
对于反复 运行 这个问题的任何人,我已经弄清楚出了什么问题。尽管错误通知我我的 JSON 格式不正确,但事实证明实际上是 module
被错误命名。根据 this post,更新模块已重命名为 '@parse/simple-mailgun-adapter'
。在确保我的本地存储库中有 运行 和 npm install --save @parse/simple-mailgun-adapter
后,将其插入 index.js
,解决了这个问题。
我有一个由 heroku 托管的解析服务器,它有一个用于配置的 index.js
文件。我想使用 Mailgun 来为用户提供重设密码的功能,并且我已经按照 this answer 设置了配置文件,如下所示:
var api = new ParseServer({
appName: 'App Name',
publicServerURL: 'https://<name>.herokuapp.com/parse',
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 $
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't$
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query s$
},
push: JSON.parse(process.env.SERVER_PUSH || "{}"),
verifyUserEmails: true, //causing errors
emailAdapter: { //causing errors
module: 'parse-server-simple-mailgun-adapter',
options: {
fromAddress: 'parse@example.com',
domain: '<domain>',
apiKey: '<key>',
}
}
});
不过,由于 verifyUserEmails
和 emailAdapter
,此代码不起作用。删除它们会删除 "JSON text did not start with array" 错误。将它们中的任何一个添加回去都会导致抛出错误。不过,我不知道为什么,因为我没有看到任何明显的原因说明它们没有正确地设置在数组中?
除了将它们放在配置文件中之外,我是否需要在 heroku 中设置相应的配置变量?我考虑过这个,但是appName
和publicServerURL
不是这样设置的,不要报这个错。
emailAdapter.options.apiKey 末尾不需要逗号,因为它的最后一个元素是 JSON.
当您不正确地包含 verifyUserEmails 时,如果您在末尾也留下逗号,我不会感到惊讶。
options: {
fromAddress: 'parse@example.com',
domain: '<domain>',
apiKey: '<key>',
}
这是无效的 JSON,因为 apiKey 行末尾有一个逗号。 JSON 对象中的最后一项没有逗号。
对于反复 运行 这个问题的任何人,我已经弄清楚出了什么问题。尽管错误通知我我的 JSON 格式不正确,但事实证明实际上是 module
被错误命名。根据 this post,更新模块已重命名为 '@parse/simple-mailgun-adapter'
。在确保我的本地存储库中有 运行 和 npm install --save @parse/simple-mailgun-adapter
后,将其插入 index.js
,解决了这个问题。