Filter doesn't work alone (Cannot read property 'then' of undefined)

Hey Community,
my filter doesn’t work, if I only use 1 Filter.

Here’s the error: TypeError: Cannot read property ‘then’ of undefined

I have 3 Filters: textbox, checkboxGroup, Radiobuttons.

Here’s my code:

$w.onReady(function () {
    $w('#dataset1').onReady(() => {
        $w('#dataset1').new();
    })
})

// Filter
let lastFilterTitle;

function FilterDataset(title) {
 let filter = wixData.filter()
 var ValueCheckbox = $w("#checkboxValue").value;
 var ValueRadioButtons = $w("#RadioButtonsValue").value;

 if (ValueCheckbox) { filter = filter.hasSome("aaa", ValueCheckbox ) }

 if (ValueRadioButtons) { filter = filter.hasSome("bbb", ValueRadioButtons ) }

 if (lastFilterTitle !== title) {

     if (title) filter = filter.contains('title', title).or(filter.contains("location",             
     title))

        lastFilterTitle = title;
    }

    $w('#dataset1').setFilter(filter)
}

// Search - title and location
let debounceTimer;

function debounce(event) {
 if (debounceTimer) {
        clearTimeout(debounceTimer);
        debounceTimer = undefined;
    }
    debounceTimer = setTimeout(() => {
        FilterDataset($w("#Searchbar").value);
    }, 200);
}

// functions
export function Suchen_click(event) {
    FilterDataset()
    debounce()
}

Thanks for your help.

Debugging should be a payed job.:grin:

Yeah :joy:

The problem I think is, that I don’t return the promise.

So I have to add a code, but where ?

.find()
.then((results) => {
 return results.items;
            });