Format element based on boolean value

Hi,
The query is only used to get the data, you shouldn’t use it inside the condition.
try the following code and remember to change the query and the ID of the elements to match your site.

wixData.query("myCollection")
  .eq("title", "Dr.")
  .find()
  .then( (results) => {
    let boolean = results.items[0].approved;
    if(boolean == "true"){
     $w("#box").style.backgroundColor = "#ffff"; 
     } 
     else{ 
     $w("#box").style.backgroundColor = "#ef0"; 
     }
  } )
  .catch( (err) => {
    let errorMsg = err;
  } );