I am writing a program that is accessing a database and returning a specific value stored in the database. In this particular instance, I am accessing a database which has a document called "basementER" and then accessing its "status" field. This field is supposed to contain the value of "0".
The program accesses this value and even prints it to the console correctly inside of the method. However, when I try to return this value and print it to the console from the outside, I get "undefined"?
Why could this be happening? It doesn't make sense to me. Thanks in advance!
Here is my code and with comments I show the results
 var testRoom = "basementER";
  var rawStatus = getRawStatus(testRoom);
  console.log(rawStatus);  //prints undefined to console
  function getRawStatus (room)
  {
    db.collection("rooms").doc(room).get().then(function(doc) {
      console.log(doc.data().status); //prints 0 to console
      var rawStatus = doc.data().status;
      console.log(rawStatus); //prints 0 to console
      return rawStatus;
    })
  }//end getRawStatus
