Skip to content

Commit

Permalink
Merge 8c947dd into 6feca77
Browse files Browse the repository at this point in the history
  • Loading branch information
dhivyada committed Apr 3, 2020
2 parents 6feca77 + 8c947dd commit 84670cd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/Autocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ export default {
}
return this.resourceSearch(this.source + this.display)
case this.source.constructor.name === 'AsyncFunction':
// No resource search with no input
if (!this.display || this.display.length < 1) {
return
}
// When the function is async and returns a promise
return this.handlePromise(this.source(this.display))
case typeof this.source === 'function':
// No resource search with no input
if (!this.display || this.display.length < 1) {
Expand Down Expand Up @@ -279,6 +286,10 @@ export default {
headers: this.getHeaders()
})
return this.handlePromise(promise)
},
handlePromise: function (promise) {
return promise
.then(response => {
if (response.ok) {
Expand All @@ -297,7 +308,6 @@ export default {
this.loading = false
})
},
/**
* Set some default headers and apply user supplied headers
*/
Expand Down

0 comments on commit 84670cd

Please sign in to comment.