Compact code to map results from search API into SearchResult objects

Make code compact for readability
Remove unneeded temporary variables and return statements
This commit is contained in:
Debanjum Singh Solanky
2023-01-17 17:44:35 -03:00
parent 7b4f78776c
commit d5a7cc5b0f

View File

@@ -54,15 +54,8 @@ export class KhojModal extends SuggestModal<SearchResult> {
let searchUrl = `${this.setting.khojUrl}/api/search?q=${query}&n=${this.setting.resultsCount}&r=${this.rerank}&t=markdown` let searchUrl = `${this.setting.khojUrl}/api/search?q=${query}&n=${this.setting.resultsCount}&r=${this.rerank}&t=markdown`
let results = await request(searchUrl) let results = await request(searchUrl)
.then(response => JSON.parse(response)) .then(response => JSON.parse(response))
.then(data => { .then(data => data
return data.map((result: any) => { .map((result: any) => { return { entry: result.entry, file: result.additional.file } as SearchResult; }));
let processedResult: SearchResult = {
entry: result.entry,
file: result.additional.file
};
return processedResult;
})
});
return results; return results;
} }