Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function getByNameProm (name) {
const fullSummary = await getSummary({}).then(sendToApi);
const filteredOrgs = _.filter(fullSummary.organisations, { name });
if (filteredOrgs.length === 0) {
throw new Error('Organisation not found');
}
if (filteredOrgs.length > 1) {
throw new Error('Ambiguous organisation name');
}
return filteredOrgs[0];
}