@ajithkrr you’re trying to split the text of the hasTags field. How ever this field doesn’t contain any text value for some of the records. And it cannot split an undefined value. So add .isNotEmpty(“hasTags”) to your query.
@jonatandor35 Thanks !
Your code worked!!!
Actually, the field’s id was “hashTags”
Here’s the final code →
wixData.query("userCreations")
.isNotEmpty("hashTags")
.find()
.then((results) => {
if (results.items.length > 0) {
let items = results.items;
const firstWrods = results.items.map(e => e.hashTags.split(" ")[0]);
console.log("first words " + firstWrods)
}
});
One more thing !!
I am having a repeater in my page.
In the repeater 2 texts.
I am getting the first words from the field “hashTags”.
Now, in the database, there is another text field called “name”.
When I get the first words, can I also get the corresponding value from the field “name” and assign the both to repeater.