Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
746 views
in Technique[技术] by (71.8m points)

node.js - firebase cloud functions async await error

Using async await with firebase cloud functions gives an error:

18:68 error Parsing error: Unexpected token =>

? 1 problem (1 error, 0 warnings)

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! functions@ lint: eslint .

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the functions@ lint script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

There are a couple of questions like this one, suggesting to put:

"parserOptions": {
   "ecmaVersion": 2017
}

inside functions/.eslintrc.json. However, there's no such file in my firebase project, only .eslintrc.js.

How should i proceed?

Here's the code

exports.onUserCreate = functions.auth.user().onCreate(async (user) => {
    try {
        const data = {
            "name": user.displayName,
            "uid": user.uid,
        };
        await firestore.collection('users').doc(user.uid).set(data);
    } catch (err) {
        console.log(err);
    }
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...