I have code that runs mongoose and successfully returns the following results.
Why can't I do the following and get values from my object?
Object.keys(result).forEach(function(record){
console.log("The value of result[record]: ", result[record]);
})
How do I iterate through this object to get the different keys to get the values in both lists and objects?
I'm using plain vanilla javascript. But I wouldn't mind some of the newer ES options.
{ owner: { fullName: 'xxx', userName: 'xxx' },
members: [ { userName: 'xxx', fullName: 'xxx', position: '' } ],
admins: [ 'xxx','ashg' ],
_id: 5a482302a469a068edc004e3,
type: 'xxxx',
name: 'xxxx xxxx',
descrip: 'xxxx',
startDate: '2018-01-01',
endDate: ''
}
Here is a simpler example of what I want to replicate and that works exactly as expected:
var o={a:1,b:2,c:3};
var val;
Object.keys(o).forEach(function(key) {
val = o[key];
console.log(val);
});
Output: 1,2,3