P
P
Pavel Talaiko2020-12-22 17:44:28
Angular
Pavel Talaiko, 2020-12-22 17:44:28

How to collect a single entity from different APIs in Angular 8?

Hi, friend.

So the situation is this.
These entities lie in different services and are obtained through different APIs:

export interface Person { // /api/persons
    id: string;
    name: string;
    car: string; // идентификатор car
}

export interface Car { // /api/cars
    id: string;    
    title: string;
}


I want to get a list when loading /api/persons:

Artur Stepanovich BMW X6
Mikhail Ivanovich Audi A8

Persons
[
{"id": "ef2e65df-003a-42a8-881c-2108a0f59d75", "name": "Артур Степанович", "car": "cdec0e14-55f0-49eb-ae96-82006b95cdf2" },
{"id": "f7123c17-fee1-47b6-8391-aed83dc77565", "name": "Михаил Иванович", "car": "2ca4fa1f-7936-4717-9661-0ef773db1a14" }
]

cars:
[
{"id": "cdec0e14-55f0-49eb-ae96-82006b95cdf2", "title": "BMW X6" },
{"id": "2ca4fa1f-7936-4717-9661-0ef773db1a14", "title": "Audi A8" }
]


How to download correctly? How to display correctly?
How do you do it? How do you work with state NGRX in this case?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question