0

When trying to deploy my cloudfunction with: firebase deploy --only functions I get this error:

22:24 error Parsing error: Unexpected token user

This is my code:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
const db = admin.firestore();

exports.addFriend = functions.https.onCall((data, context) => {
    let user = db.collection('user');
    let friend = await user.where('email', '==', data.email).get();

    if (friend != null) {
        console.log(friend.data()['id']);
    }
});

The error links to the line with await user.where... I did stuff like this before and it worked. I can't see what I am doing different.

Anyone sees my mistake?

1 Answer 1

1

If you want to use await, you have to declare the enclosing function as async:

exports.addFriend = functions.https.onCall(async (data, context) => {
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.