Filter Options Node

Any idea why this code doesnt work? Until the commented part everything works. I get all the data from the api but cant filter it.

 fetch(url)
          .then((res) => res.json())
          .then((data) => {
            opt = data;
            console.log(data);
            opt.forEach((item) => {
              options.push({
                //v: `SUBSCRIBE ${item.deviceName} ${item.name} WebEvent/1.0`,
                v: `SUBSCRIBE ${item.name} WebEvent/1.0`,
                t: item.name,
              });
            });
            for (let i = 0; i < options.length; i++) {
              let value = options[i].v;
              let text = options[i].t;
              $("#node-input-options").append(
                $("<option></option>").attr("value", value).text(text)
              );
              // Until Here Everything Works
              let inputEl = $("#node-input-filter");
              inputEl.on("keyup", () => {
                var keyword = $("#node-input-filter");
                var fleet = $("#node-input-options");

                var txt = fleet.options[i].text();
                if (
                  txt.substring(0, keyword.length).toLowerCase() !==
                    keyword.toLowerCase() &&
                  keyword.trim() !== ""
                ) {
                  fleet.options[i].style.display = "none";
                } else {
                  fleet.options[i].style.display = "list-item";
                }

You need to explain what 'works' means to you. What is the expected behaviour of this code. What does it do?

Until the comment the code gets the data and stores it in the dropdown that triggers oneditprepare.
For now i have 8 objects given back and Im displaying their name.
I want to make a filter because later on i will have 100 of objects

. This is my node.

I almost made it work.

     let selectTag = $("#node-input-options")[0];
            let inputEl = $("#node-input-filter").val().toLowerCase();
            let elem = $("#node-input-filter");
            for (let i = 0; i < options.length; i++) {
              let value = options[i].v;
              let text = options[i].t;

              $("#node-input-options").append(
                $("<option></option>").attr("value", value).text(text)
              );
              const filter = () => {
                let optionEl = options[i];
                let txt = selectTag.options[i].text;
               
                selectTag.options[i].style.display =
                  txt.search(new RegExp(inputEl.replace(/\s+/, "|"))) != -1
                    ? ""
                    : "none";
              };
              elem.on("keyup", filter());

The problem now is that it doesnt always filter. When i try to filter with letter s i get nothing back. When i filter with letter ee i get all 3 speed etc