Help with Wix Code SDK Error - Invalid rgbaColor

I’m having some issues figuring out why I’m getting this error. The Code is working as intended but I’m getting the following error.

Here is my Code -

$w.onReady(function () {
$w('#dynamicDataset').onReady( () => {
$w('#repeater1').onItemReady(() => {
$w('#repeater1').forEachItem(($i, data, i) => {
if( data.primaryColor === null)
{
$i('#box2').style.backgroundColor = "#05136f";
}
else
{
$i('#box2').style.backgroundColor = data.primaryColor;
}

if( data.secondaryColor === null)
{
$i('#box3').style.backgroundColor = "#f0f0f0";
}
else
{
$i('#box3').style.backgroundColor = data.secondaryColor;
}
});
});
});
});

Not sure what I’m doing wrong here, any help is greatly appreciated.

1 Like

can you console log primary color?
I will double check the fieldkey “primaryColor;”

This error occurs when u send an empty string, undefined, null.

instead of:

if( data.primaryColor === null)

Try:

if(!data.primaryColor)

And the same for the secondaryColor

Thank you so much! This worked perfectly!

@skscreative You’re welcome.
(It’s because null and undefined are two different things).