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

Categories

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);
    }
});

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

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...