Need help with code for selection tags

Based on this example , I am trying to use selection tags on a sample blog page so that users can narrow down blog posts to those that have more than one category in common. Right now, I’m trying to get the database query set up properly.

This is the code I’ve written:

import wixData from 'wix-data';

$w.onReady(function () {
    $w('#tags').onChange((event) => {
 const selectedTags = $w('#tags').value;
    console.log(selectedTags);
    loadDataToBlog(selectedTags);
    })
});

async function loadDataToBlog(selectedCategories = []) {
 let dataQuery = wixData.query("Blog/Posts");
 if(selectedCategories.length > 0) {
        dataQuery = dataQuery.hasAll('categories', selectedCategories);
    }
 let results = await dataQuery.find();
    console.log(results);
}

Under my posts database, I have two posts saved within a “Shoutouts” category as listed in the category field for those ones:

So according to the code I’ve written, I’m expecting to see two items listed in the results variable, but that does not seem to be the case unfortunately

Any clue as to what I might have done incorrectly?

Also I used this link to try and resolve but it didn’t help: https://www.wix.com/corvid/forum/community-discussion/filtering-blog-posts-to-a-repeater-code-problem

Expand the query: {…} object on console and check the literal query.

I’m not seeing anything under the query object?

Please try using promise instead async/await.

function loadDataToBlog ( selectedCategories = [] ) {
console.log(’ selectedCategories: ', selectedCategories);
return wixData . query ( “Blog/Posts” ) //this returns from function
. hasAll ( ‘categories’ , selectedCategories )
. find ()
.then(results => {
console . log ('results: ', results );
return results; // If you need to return results => this returns from .then()
})
.catch(err => {
console.log('error: ', err);
});
}


function loadDataToBlog(selectedCategories = []) {
    console.log('selectedCategories: ', selectedCategories);
 return wixData.query("Blog/Posts")
    .hasAll('categories', selectedCategories)
    .find()
    .then(results => {
        console.log('results: ', results);
 return results;
    })
    .catch(err => console.log('error: ', err));
}

^^ This is how copied your code into my page code. But it seems the query still doesn’t work