diff --git a/src/server/api.ts b/src/server/api.ts index afe855b..88de4d6 100644 --- a/src/server/api.ts +++ b/src/server/api.ts @@ -10,6 +10,14 @@ setGlobalDispatcher(new ProxyAgent(process.env.HTTPS_PROXY as string)); export default function (server, opts, done) { server.get("/flight/:id", async (req, reply) => flight_get_data(req.params.id) + .then(res => { + let wait_for_all: Promise[] = [] + res.forEach(r => { + wait_for_all.push(nominatim_get_data(r.from).then(geo => (r as any).from_geo = geo[0])); + wait_for_all.push(nominatim_get_data(r.to).then(geo => (r as any).to_geo = geo[0])); + }); + return Promise.all(wait_for_all).then(_ => res) + }) .then(res => reply.send(res)) );