I have a class with an array of object.
export interface Filter {
sf?:Array<{key:string,value:string}>;
}
I try to use forEach function to loop and log each object value inside the array.
f : Filter = {sf:[{key:'a',value:'b'},{key:'c',value:'d'}]};
f.sf.forEach(element => {
console.log(element.key);
});
However error appears inside the mongo db server.
[error] f.sf.forEach is not a function 0
node | TypeError: f.sf.forEach is not a function
how can I fix this error so the forEach works? thank you.
f.sfisundefinedas permitted by the Filter interface definition?