diff --git a/src/modules/api/api.ts b/src/modules/api/api.ts index 815cc75..8b51c88 100644 --- a/src/modules/api/api.ts +++ b/src/modules/api/api.ts @@ -1106,9 +1106,15 @@ function GetApp(): ModuleType { return getResult(question, subj, null, req.query) }) - Promise.all(resultPromises).then((result) => { - console.log(result) - res.json(result) + Promise.all(resultPromises).then((results) => { + res.json( + results.map((result: any) => { + return { + answers: result.result, + question: result.question, + } + }) + ) }) }) @@ -1145,6 +1151,8 @@ function GetApp(): ModuleType { function getResult(question, subj, recData, recievedData) { return new Promise((resolve) => { + // searchIn could be [0], [1], ... to search every db in different thread. Put this into a + // forEach(qdbs) to achieve this doALongTask({ type: 'work', data: { @@ -1154,17 +1162,17 @@ function GetApp(): ModuleType { questionData: recData, }, }) - .then((result) => { - console.log(result) + .then((taskResult) => { try { logger.DebugLog( - `Question result length: ${result.length}`, + `Question result length: ${taskResult.length}`, 'ask', 1 ) - logger.DebugLog(result, 'ask', 2) + logger.DebugLog(taskResult, 'ask', 2) resolve({ - result: result, + question: question, + result: taskResult.result, success: true, }) } catch (err) {