title: Firebase snapshot returns null
body: <p>Hi guys I have been using firebase to write and read values from the database. It was working awesome until I wrote a function to retrieve values or products stored using swift in the following way.</p>
  
  <p>Here is my code</p>
  
  <pre><code>func retrieveLiveUrlFor(product: Product){
      if let path = product.prodRef{
          print("Looking for : \(path)")
          var liveUrl = ""
          let ref = Database.database().reference(withPath: path)
          ref.observe(. value, with: {
              snapshot in
              print("Snap : \(snapshot.value)")
              if snapshot.exists(){
                  print("Snap : \(snapshot.value)")
                  let dic = snapshot.value as? NSDictionary
                  if dic != nil{
                      let url = dic?["liveUrl"] as? String
                      print("Url is here")
                      if url != nil{
                          print("URL is not nil")
                          liveUrl = url as! String
                      }
                  }
              }
  
              if (self.productdelegate != nil){
                  print("Calling Product delegate")
                  self.productdelegate?.liveUrlObtained!(liveUrl: liveUrl)
              }
          })
      }
  }
  </code></pre>
  
  <p>And this is the value of the path that I am trying to retrieve</p>
  
  <blockquote>
    <p>Products/Live/Global/WpMvDJZUclRlfHFJsSlBEbi0jHf1</p>
  </blockquote>
  
  <p>And here is the snap of the firebase database</p>
  
  <p><a href="https://i.stack.imgur.com/YnJgZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YnJgZ.png" alt="enter image description here"></a></p>
  
  <p>The snapshot.value alwasy returns null in swift.
  When I print using </p>
  
  <pre><code>print("Snap: \(snapshot.value)")
  </code></pre>
  
  <p>It prints the following</p>
  
  <blockquote>
    <p>Snap : Optional()
    Please guide me what I am doing wrong so that I can get to it.</p>
  </blockquote>