Hi friends,
I am trying to return a filter from a backend function in the frontend and then pass the result to the dynamicDataset.setFilter() function. However, I am getting the error below. Any thoughts on how to resolve? Thanks
// backend
export async function getNewFilter() {
let filter = await wixData.filter()
.eq("productAvailability", "Sold");
return filter;
// got the same error when I returned the line below
// return JSON.stringify(filter);
}
// frontend
// returns the error below
async function filterDataset() {
let filter = await Data.getNewFilter();
// got the same error when I returned JSON.stringify(filter) in the getNewFilter() function
// and then called JSON.parse on the result and tried to pass that to setFilter()
// filter = JSON.parse(filter);
$w("#dynamicDataset").setFilter(filter);
}
// this works fine but I want to create the filter in the backend
async function filterDataset() {
let filter2 = wixData.filter()
.eq("productAvailability", "Sold");
$w("#dynamicDataset").setFilter(filter2);
}