I am trying to get the id's from array of objects using the below code
const opaqueMaterialSecondaryIds = Object.values(library?.layers).reduce((acc, opaque) => {
acc.push(...opaque.map(e => e.id));
return acc;
}, []);
and getting an error at opaque.map is not function and the object is looks like as below
i am not sure where i am doing wrong with the above code. Could any one please suggest any ideas on this, many thanks in advance.

library?.layers?.map(item => item.id)