Browse Source

Рефакторинг

Book Pauk 2 years ago
parent
commit
5c03e06648
1 changed files with 13 additions and 41 deletions
  1. 13 41
      client/components/Api/Api.vue

+ 13 - 41
client/components/Api/Api.vue

@@ -197,69 +197,41 @@ class Api {
             } else if (response && response.error == 'server_busy') {
             } else if (response && response.error == 'server_busy') {
                 await this.showBusyDialog();
                 await this.showBusyDialog();
             } else {
             } else {
+                if (response.error) {
+                    throw new Error(response.error);
+                }
+
                 return response;
                 return response;
             }
             }
         }
         }
     }
     }
 
 
     async authorSearch(query) {
     async authorSearch(query) {
-        const response = await this.request({action: 'author-search', query});
-
-        if (response.error) {
-            throw new Error(response.error);
-        }
+        return await this.request({action: 'author-search', query});
+    }
 
 
-        return response;
+    async seriesSearch(query) {
+        return await this.request({action: 'series-search', query});
     }
     }
 
 
     async getAuthorBookList(authorId) {
     async getAuthorBookList(authorId) {
-        const response = await this.request({action: 'get-author-book-list', authorId});
-
-        if (response.error) {
-            throw new Error(response.error);
-        }
-
-        return response;
+        return await this.request({action: 'get-author-book-list', authorId});
     }
     }
 
 
     async getSeriesBookList(series) {
     async getSeriesBookList(series) {
-        const response = await this.request({action: 'get-series-book-list', series});
-
-        if (response.error) {
-            throw new Error(response.error);
-        }
-
-        return response;
+        return await this.request({action: 'get-series-book-list', series});
     }
     }
 
 
     async getGenreTree() {
     async getGenreTree() {
-        const response = await this.request({action: 'get-genre-tree'});
-
-        if (response.error) {
-            throw new Error(response.error);
-        }
-
-        return response;
+        return await this.request({action: 'get-genre-tree'});
     }    
     }    
 
 
     async getBookLink(params) {
     async getBookLink(params) {
-        const response = await this.request(Object.assign({action: 'get-book-link'}, params), 120);
-
-        if (response.error) {
-            throw new Error(response.error);
-        }
-
-        return response;
+        return await this.request(Object.assign({action: 'get-book-link'}, params), 120);
     }
     }
 
 
     async getConfig() {
     async getConfig() {
-        const response = await this.request({action: 'get-config'});
-
-        if (response.error) {
-            throw new Error(response.error);
-        }
-
-        return response;
+        return await this.request({action: 'get-config'});
     }
     }
 }
 }