Hi,
I have a dataset, and i want to filter it.
I made a function in my backend, and imported it to my page.
Now some wierd thing is happening.
this is the code.
Code on the page.
try {
$w("#dataset1").onReady(async ()=> {
const filter = await filterDataset(event.target.value) // function in the backend
const filter2 = wixData.filter().eq(event.target.value,true) // without a function
console.log("filter: ",filter)
console.log("filter2: ",filter2)
$w("#dataset1").setFilter(filter) // applying the filter.
})
} catch (err) {
console.error(err)
}
Code in the backend
export function filterDataset(value) {
let filter = wixData.filter()
try {
filter = filter.eq(value,true)
return filter
} catch (err) {
console.error(err)
}
}
Now when i log them in my console, evrything is fine
Both filters show the exact same log value.
But when i use it in the dataset.setFilter() the function from the backend gives an error the other does not.
$w("#dataset1").setFilter(filter)
Gives this error:
$w("#dataset1").setFilter(filter2)
Doesn’t give any error.
When adding the code in Public folder it also works.
I guess its becous its from the backend folder
But when it logs the right results i don’t understand why it doesn’t works when using it.
Kind regards,
Kristof.