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);
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…