var element = document.querySelector('#textinput');
element.addEventListener('keyup', handleText, false);
function handleText (e) {
// Get the text
var text = e.target.value;
// Query the service via a Promise API
queryService(text).then(function (results) {
// Handle completion
}, function (err) {
// Handle errors
});
}