Если вы собираетесь много выполнять эту операцию, вам может оказаться проще реструктурировать данные в массив.
const results = {"data":{"facets":{"60749428":{"id":60749428,"name":"KC Content Content Kind"},"60750276":{"id":60750276,"name":"KC Content Product Version"},"69107204":{"id":69107204,"name":"KC Video Audience"},"69127027":{"id":69127027,"name":"KC Content Kind ID"}}}};
// Get a list of the facet keys
const keys = Object.keys(results.data.facets);
// Pull those facet objects into an array
const arr = keys.reduce((acc, key) => acc.concat(results.data.facets[key]), []);
// Find the object that matches the required name, and return the id
const id = arr.find(el => el.name === 'KC Content Kind ID').id;
console.log(id);
Используя этот массив, вы можете написать общую функцию для сбора информации:
const arr = [{"id":60749428,"name":"KC Content Content Kind"},{"id":60750276,"name":"KC Content Product Version"},{"id":69107204,"name":"KC Video Audience"},{"id":69127027,"name":"KC Content Kind ID"}];
function findPropFromValue(arr, prop, key) {
const [sKey, sVal] = [...Object.entries(prop)];
return arr.find(el => el[sKey] === sVal)[key];
}
const id = findPropFromValue(arr, { name: 'KC Content Kind ID' }, 'id');
console.log(id);
const name = findPropFromValue(arr, { id: 69107204 }, 'name');
console.log(name);