JSFiddle - React, Tailwind, and code Playground
HTML
<input id="address" type="text" />
JavaScript
$(function() {
$("#address").autocomplete({
source: function(request, response) {
// Get geonames results
$.ajax({
url: "http://ws.geonames.org/searchJSON",
dataType: "jsonp",
data: {
featureClass: "P",
style: "full",
maxRows: 8,
name_startsWith: request.term
},
success: function( data ) {
response( $.map( data.geonames, function(item) {
return {
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
value: item.name
}
}));
}
});
},
minLength: 2
});
});