function loadTheThings () { 
    $("tbody").text("");
    $.get(`${API_URL}.json?auth=${token}`)
      .done((data) => {
        //if the object doesn't exist, firebase will return null. ONE WAY:
        //if (data===null) {
          //return //get out of the function and stop. 
        //}
        //ANOTHER WAY: 
        if (data) {
          //append the data to the page. 
          Object.keys(data).forEach((id)=>{
            addItemToTable(data[id], id); //note I'm passing in the ID here so I can grab the individual message later. 
            if (data[id].completed === true) {
              console.log("hey this one is completed", id );
              completeItem(id);
            }
          //other option: for (key in data) {
          //  addItemToTable(data[key])
          //  }
          }); //otherwise don't do anything. 'null' is falsy.
        }
      });
  }
//READ: GET data from firebase and display in table. Runs at start. Could technically also run at submit button if I assigned it a name, but see below for instead.
GET data from firebase and display in table. Runs at start. Could technically also run at submit button if I assigned it a name, but see below for instead.
GET data from firebase and display in table . Runs at start . Could technically also run at submit button if I assigned it a name but see below for instead .
function loadTheThings () { 
    $("tbody").text("");
    $.get(`${API_URL}.json?auth=${token}`)
      .done((data) => {
        if (data) {
          Object.keys(data).forEach((id)=>{
            addItemToTable(data[id], id); 
            if (data[id].completed === true) {
              console.log("hey this one is completed", id );
              completeItem(id);
            }
          }); 
        }
      });
  }
function loadTheThings ( ) { $ ( "tbody" ) . text ( "" ) ; $ . get ( ` ${ API_URL } ${ token } ` ) . done ( ( data ) => { if ( data ) { Object . keys ( data ) . forEach ( ( id ) => { addItemToTable ( data [ id ] , id ) ; if ( data [ id ] . completed === true ) { console . log ( "hey this one is completed" , id ) ; completeItem ( id ) ; } } ) ; } } ) ; }
READ: GET data from firebase and display in table.
READ : GET data from firebase and display in table .
//if the object doesn't exist, firebase will return null. ONE WAY: //if (data===null) { //return //get out of the function and stop.  //} //ANOTHER WAY:  //append the data to the page.  //note I'm passing in the ID here so I can grab the individual message later.  //other option: for (key in data) { //  addItemToTable(data[key]) //  } //otherwise don't do anything. 'null' is falsy.