I am currently doing some Angular Ionic project with Firestore and stuck with one problem. Take following code as an example:
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);
}
});
In my database I have following field:
Upon running the code, I get following error:
Error: Uncaught (in promise): TypeError: interested.keys is not a function. (In 'interested.keys()', 'interested.keys' is undefined)
When I checked the type of "interested", it returned object while I expected it to be Map. Actually, none of the Map methods work on that variable. I want to use such methods, however, I do not know how to make them work. Why it does not work and what should I do? May be I have to convert data Firestore returns into JSON object?