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();
}
CodePudding user response:
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
}