Skip to content
Snippets Groups Projects
Commit dcb33611 authored by schneider210's avatar schneider210
Browse files

refactor: use try-catch-finally according to the review proposal

pls refer to !60 (comment 370134)
parent fc29c072
No related branches found
No related tags found
1 merge request!60loading indicator for search
Pipeline #219551 passed
......@@ -75,13 +75,19 @@ export default {
this.search(this.query, 0, this.size)
},
async search(value, from, size) {
this.loading = true;
const searchResponse = await apiService.search(value, from, size);
let searchResponse;
if (searchResponse) {
this.loading = false;
const items = searchResponse.hits?.hits;
try {
searchResponse = await apiService.search(value, from, size);
} catch(error) {
// handle error here ...
} finally {
this.loading = true;
}
if (searchResponse) {
this.loading = false;
const items = searchResponse.hits?.hits;
if (items) {
this.total = searchResponse.hits?.total.value || 0;
this.items = items.map(x => ({ ...x, searchTerm: value }));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment