feature: add real get entity by name

This commit is contained in:
Nikita Nek Dudnik
2020-05-28 16:04:52 +02:00
parent 81229772aa
commit 4e9d5a10c4
+4 -2
View File
@@ -41,8 +41,10 @@ export class CatalogApi {
return await response.json();
}
async getEntityByName(name: string): Promise<DescriptorEnvelope> {
const entities = await this.getEntities();
const entity = entities.find(e => e.metadata.name === name);
const response = await fetch(
`${this.apiOrigin}${this.basePath}/entities/by-name/Component/default/${name}`,
);
const entity = await response.json();
if (entity) return entity;
throw new Error(`'Entity not found: ${name}`);
}