Reputation: 131
I have done some googling and haven't found an answer to my question. I am following the tutorial for google firebase functions here and have copied index.js
exactly from the GitHub repository linked on the tutorial as well as copying the code in 'chunks' by following the tutorial and I get this error after running firebase deploy --only functions
error Parsing error: Unexpected token =>
which references this function:
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]
}));
Link to index.js file used in tutorial
My eslintrc.js
file:
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"google",
],
rules: {
quotes: ["error", "double"],
},
};
Upvotes: 0
Views: 191
Reputation: 50830
Async functions and await keyword were added in ECMAScript 2017. You need to set ecmaVersion
to 8
in your ESLint config.
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"google",
],
parserOptions: {
ecmaVersion: 8
},
rules: {
quotes: ["error", "double"],
},
};
Upvotes: 1