Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
connect() {
const inputElement = this.element
autocomplete({
input: inputElement,
emptyMsg: 'No items found',
fetch(text, update) {
// Query JSON API, which returns words
fetch(`/api/v1/posts/autocomplete?q=${text}`)
.then((response) => response.json())
.then((words) => update(words))
},
render(item) {
const div = document.createElement('div')
div.textContent = item
return div
},