@dbp-toolkit/check-in-place-select
Version:
You can install this component via npm:
22 lines (18 loc) • 466 B
JavaScript
/**
* Finds an object in a JSON result by identifier
*
* @param identifier
* @param results
* @param identifierAttribute
*/
export const findObjectInApiResults = (identifier, results, identifierAttribute = "@id") => {
const members = results["hydra:member"];
if (members === undefined) {
return;
}
for (const object of members){
if (object[identifierAttribute] === identifier) {
return object;
}
}
};