简体   繁体   中英

get clean data in firebase query

I am making a query to retrieve information from my current user, the query works perfectly but the data I receive has a lot of information.

在此处输入图像描述

I would like to get only the object where the user information is.

This is my query:

export const GetUserDB = async (userId) => {
    const response = await db
        .collection('users')
        .where("id", "==", userId)
    return response.get();
}

Let me know if it worked for you.

 export const GetUserDB = async (userId) => { const response = await db.collection('users').where("id", "==", userId).get() const usersArray = response.docs.map(each => each.data()) return usersArray[0] // returning the first document from the array }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM