谷歌火碱函数教程意外令牌 =>



我在谷歌上搜索了一下,还没有找到问题的答案。我在这里遵循谷歌firebase函数的教程,并从教程上链接的GitHub存储库中准确复制了index.js,并通过遵循教程以"块"形式复制代码,在运行firebase deploy --only functions后我收到了这个错误

error Parsing error: Unexpected token =>

它引用了这个函数:

exports.addMessage = (functions.https.onRequest(async (req, res) => { //This line
// [END addMessageTrigger]
// Grab the text parameter.
const original = req.query.text;
// [START adminSdkAdd]
// Push the new message into Firestore using the Firebase Admin SDK.
const writeResult = await admin.firestore().collection('messages').add({ original: original });
// Send back a message that we've successfully written the message
res.json({ result: `Message with ID: ${writeResult.id} added.` });
// [END adminSdkAdd]
}));

教程中使用的index.js文件的链接

我的eslintrc.js文件:

module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"google",
],
rules: {
quotes: ["error", "double"],
},
};

在ECMAScript 2017中添加了异步函数和await关键字。您需要在ESLint配置中将ecmaVersion设置为8

module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"google",
],
parserOptions: {
ecmaVersion: 8
},
rules: {
quotes: ["error", "double"],
},
};

相关内容

  • 没有找到相关文章

最新更新