Dataset Filter returns undefined after filtering

I want to filter my dataset by matching the orderId which is unique for every entry in the dataset. I have written code for filtering but it is returning undefined. On click of the button in the repeater, that particular orderId needs to be taken and matched with the dataset and return the result. With the returned data I am going to call an API to perform other functionalities. It is my college project and
it would be great if someone could help me with this.

import {local} from 'wix-storage';
import wixWindow from 'wix-window';
import wixData from 'wix-data';

$w.onReady(function (){
  console.log("getTotalPageCount() function - " +$w("#dynamicDataset").getTotalPageCount());
  let records = $w("#dynamicDataset").getItems();
  console.log("this is data" + records);
});

export async function onButtonClick (event) {
  let $item = $w.at(event.context);
  console.log($item('#orderId').value);
  let orderIdToSend = $item('#orderId').value;
  console.log("getTotalPageCount() function - " +$w("#dynamicDataset").getTotalPageCount());

  $w("#dynamicDataset").setFilter(wixData.filter()
            .eq("Order_ID", orderIdToSend))          
            .then((results)=>{
              console.log("results - " + results);
              let data = ($w("#dynamicDataset").getItems());
              console.log("this is data" + data);
              console.log("Dataset is now filtered by", orderIdToSend);
              console.log(results.items);
            })
            .catch((error) => {
             let errorMsg = error.message;
             let code = error.code;
             console.log("Catch - " + errorMsg); 
            });
}

I’m not 100% sure but if you do getItems() to a variable yoi should use the variable.items to return it.
So console.log(" this is data " + data)
Should be
Console.log(“this is data” + data.items)

Kristof.

Hi Kristof, thank you so much for responding. I tried what you said but that isnt work it still shows same errors saying undefined.
Could you just tell me if there is any way that i fetch all the data i need from the dataset to run an API and store it in the form of an object on the repeater itself for every record. So that i dont have to worry if data is fetched after filtering. Infact there won’t be a need to filter at all. Is there something like this?

@killekaraditi50 At one point, I thought that setFilter returns data results like wixData.query, wixData.get, and dataset.getItems. It doesn’t. A close look at the documentation confirmed that for me:

Promise
Fulfilled - When the filter has been set. Rejected - An error object.

@tony-brunsman this was really helpful as I atlest got to know that i have to try something else as dataset won’t return data. Thank you very much.
Could you suggest me any method where I can fetch data that matches with the order Id and make a API call. Can I work with database on the page where i have put a repeater which is connected to dataset?