Currently, I am working on a cloud function in TypeScript, where I am attempting to retrieve a Map object (also known as nested objects or maps) from Firebase in order to iterate through it.
Here is the structure of my Firebase data:
https://i.sstatic.net/clICC.png
My goal is to access the data like this:
const tokenSettingsRef = db.collection('tokenSettings').doc('spread')
transaction.get(tokenSettingsRef).then((tokenSettingsDocSnapshot) => {
const tokenData = tokenSettingsDocSnapshot.data()
if (typeof tokenData !== 'undefined') {
console.log("token name 3: " + tokenData.tokens[0])
console.log("token name 4: " + tokenData)
console.log("token name 5: " + tokenData.tokens)
console.log("token name 1: " + tokenData.tokens.length)
console.log("token name 2: " + tokenData.tokens.keys())
const variations = new Map(Object.entries(tokenData.tokens));
console.log("token name 5: " + variations.keys)
console.log("token name 6: " + variations.values)
}
However, none of the approaches above are providing me with the Map I need to use or even log out. The data I am receiving appears to be something like [object Object]
.
I have successfully retrieved arrays and plain objects before, so I am puzzled about what I am missing here.