Currently working on an Angular Ionic project with Firestore and encountering a problem. Here is the code snippet that I am struggling with:
handler: data => {
firebase.firestore().collection("categories").doc(`${data.name}`).get()
.then((ds) => {
if (!ds.exists){
console.log("No such category");
}
else{
let data = ds.data();
let interested : Map<string, boolean> = data["interested"];
console.log(Array.from(interested.keys());
console.log(interested);
}
});
My database has the following field:
Upon executing the code, the error message I receive is as follows:
Error: Uncaught (in promise): TypeError: interested.keys is not a function. (In 'interested.keys()', 'interested.keys' is undefined)
After checking the type of "interested", I found it to be an object instead of a Map, leading to none of the Map methods functioning on this variable. I would like to utilize these methods but unsure of how to make them work. Why are they not working and what steps should I take? Perhaps converting the data returned by Firestore into a JSON object could help?