autocomplete-widget
v1.0.2
Published
Autocomplete widget
Downloads
3
Maintainers
Readme
Autocomplete widget
Installation
yarn add autocomplete-widget
Quick start
type ItemType = {
name: {common: string, official: string}
}
const input = document.querySelector<HTMLInputElement>('input#form_country')!;
const autocompleter = new Autocompleter<ItemType>(input, item => item.name.common);
autocompleter
.setFetcher((text: string) => {
return fetch('https://restcountries.com/v3.1/name/' + text)
.then(response => response.json());
})
.onSelect((item: any) => {
alert(item.name.official);
})
.create()
;