I'm currently working with a class that contains an array of objects.
export interface Filter {
sf?: Array<{ key: string, value: string }>;
}
In my attempt to loop through and print out the value of each object inside the array using the forEach function,
f: Filter = {sf: [{key:'a', value:'b'}, {key:'c', value:'d'}]};
f.sf.forEach(element => {
console.log(element.key);
});
An error message keeps popping up from the mongo db server.
[error] f.sf.forEach is not a function 0
node | TypeError: f.sf.forEach is not a function
Can anyone provide guidance on how to resolve this error so that the forEach method can be executed successfully? Thank you in advance.