jquery – Live search with javascript

I want to get data from API with javascript and make live calls. But I’m not sure exactly how to do this.

function findMatch(wordToMatch, _allCategoriesIdName) {
return _allCategoriesIdName.filter((categories) => {
    // let newText = wordToMatch.searcText();
    const regex = new RegExp(wordToMatch.toUpperCase().replaceAll(/(İi)/gi, '(iİ)'), 'i');
    // const regex = new RegExp(newText, 'giu');
    // const regex = new RegExp(wordToMatch, 'iu');
    if (categories.name.match(regex) == '') {
    } else {
        return categories.name.match(regex);
    }
    // return categories.KategoriAdi.match(regex) || categories.KategoriNo.match(regex);
});

}