Why is the "Error" message not appearing when repeater has no results?

This is my code:

import wixData from ‘wix-data’;

$w.onReady( function () {
errorTextResult();

});

export function input1_keyPress(event) {
let SearchValue = $w(“#input1”).value;
$w(“#dataset1”).setFilter(wixData.filter().contains(‘location’, SearchValue))
}

function errorTextResult () {
$w(“#dataset1”).onReady( () => {
let count = $w(“#dataset1”).getTotalCount();

if (count > 0) {
$w(“#text4”).hide();
}

if (count === 0)
$w(“#text4”).show();
}
);
}

You’re missing a curly parentheses: { and that might cause an error.
It should be:

//....code..
if (count === 0) { // <<<< attention
    $w("#text4").show();
} 
//code...

Sorry, now I see that’s not the problem, because the closing parentheses belongs to the datase.onReady() function.
So I don’t know. Try console.log() to check if you get the correct total.

Hi @jonatandor35 !

Where shall I write “console.log()” within the code above?

@callumsaffet after the line of " let count = $w(" #dataset1 ").getTotalCount(); ", put:

console.log(count);

and see what it logs to the console.

@jonatandor35 Thank you, but it still doesn’t work.

@callumsaffet what does it log to the console?

@jonatandor35 Where do I go to check?

@callumsaffet ,
In preview mode: open the console (it’s where your code is, but in preview mode it shows the console.)

On you live site (Chrome): click F12 then select the console tab.