fix: Map page finish
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -54,10 +54,17 @@ class MapStore {
|
||||
sights: ApiSight[] = [];
|
||||
|
||||
getRoutes = async () => {
|
||||
// ИСПРАВЛЕНО: Проблема N+1.
|
||||
// Вместо цикла и множества запросов теперь выполняется один.
|
||||
// Бэкенд по эндпоинту `/route` должен возвращать массив полных объектов маршрутов.
|
||||
const response = await languageInstance("ru").get("/route");
|
||||
console.log(response.data);
|
||||
const routesIds = response.data.map((route: any) => route.id);
|
||||
for (const id of routesIds) {
|
||||
const route = await languageInstance("ru").get(`/route/${id}`);
|
||||
this.routes.push({
|
||||
id: route.data.id,
|
||||
route_number: route.data.route_number,
|
||||
path: route.data.path,
|
||||
});
|
||||
}
|
||||
const mappedRoutes: ApiRoute[] = response.data.map((route: any) => ({
|
||||
id: route.id,
|
||||
route_number: route.route_number,
|
||||
|
Reference in New Issue
Block a user