mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-03 13:19:16 +00:00
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:
@@ -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 results = await request(searchUrl)
|
||||
.then(response => JSON.parse(response))
|
||||
.then(data => {
|
||||
return data.map((result: any) => {
|
||||
let processedResult: SearchResult = {
|
||||
entry: result.entry,
|
||||
file: result.additional.file
|
||||
};
|
||||
return processedResult;
|
||||
})
|
||||
});
|
||||
.then(data => data
|
||||
.map((result: any) => { return { entry: result.entry, file: result.additional.file } as SearchResult; }));
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user