diff --git a/server/src/routes/detection_status_router.ts b/server/src/routes/detection_status_router.ts index 6d95a72..81782d5 100644 --- a/server/src/routes/detection_status_router.ts +++ b/server/src/routes/detection_status_router.ts @@ -17,13 +17,13 @@ declare type DetectionStatus = { state: DetectionState } -declare type DetectionStatusResponce = { +declare type DetectionStatusResponse = { timeranges: DetectionStatus[] } let runnnedDetections: DetectionStatus[] = []; -export async function getDetectionStatus(ctx: Router.IRouterContext): Promise { +export async function getDetectionStatus(ctx: Router.IRouterContext) { let id: AnalyticUnitId = ctx.request.query.id; if(id === undefined || id === '') { throw new Error('analyticUnitId (id) is missing'); @@ -40,7 +40,7 @@ export async function getDetectionStatus(ctx: Router.IRouterContext): Promise _.find(runnnedDetections, {id, from, to}).state = DetectionState.READY) - .catch(err => { - console.error(err); - _.find(runnnedDetections, {id, from, to}).state = DetectionState.FAILED; - }); + .then(() => _.find(runnnedDetections, {id, from, to}).state = DetectionState.READY) + .catch(err => { + console.error(err); + _.find(runnnedDetections, {id, from, to}).state = DetectionState.FAILED; + }); - return { + ctx.response.body = { timeranges: [ currentRun ]