From 120945c1a6b96066b5de00c119dd1dc20f6aab01 Mon Sep 17 00:00:00 2001 From: Hans Yadav Date: Sun, 18 Nov 2018 14:49:50 -0500 Subject: [PATCH 1/2] add onError method --- src/main.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/main.js b/src/main.js index 461ea69..4040e94 100644 --- a/src/main.js +++ b/src/main.js @@ -40,19 +40,23 @@ export default { this.loading = true - this.fetch().then((response) => { - if (response && this.query) { - let data = response.data - data = this.prepareResponseData ? this.prepareResponseData(data) : data - this.items = this.limit ? data.slice(0, this.limit) : data - this.current = -1 - this.loading = false - - if (this.selectFirst) { - this.down() + this.fetch() + .then((response) => { + if (response && this.query) { + let data = response.data + data = this.prepareResponseData ? this.prepareResponseData(data) : data + this.items = this.limit ? data.slice(0, this.limit) : data + this.current = -1 + this.loading = false + + if (this.selectFirst) { + this.down() + } } - } - }) + }) + .catch((error) => { + this.onError(error); + }) }, fetch () { @@ -124,6 +128,9 @@ export default { onHit () { util.warn('You need to implement the `onHit` method', this) + }, + + onError() { } } } From c7fec795dd51cb577498643240e9a2d31fb4cc2f Mon Sep 17 00:00:00 2001 From: Hans Yadav Date: Sun, 18 Nov 2018 14:52:35 -0500 Subject: [PATCH 2/2] loading === false on error --- src/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.js b/src/main.js index 4040e94..25964b1 100644 --- a/src/main.js +++ b/src/main.js @@ -55,6 +55,7 @@ export default { } }) .catch((error) => { + this.loading = false; this.onError(error); }) },