diff --git a/src/main.js b/src/main.js index 461ea69..25964b1 100644 --- a/src/main.js +++ b/src/main.js @@ -40,19 +40,24 @@ 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.loading = false; + this.onError(error); + }) }, fetch () { @@ -124,6 +129,9 @@ export default { onHit () { util.warn('You need to implement the `onHit` method', this) + }, + + onError() { } } }