title: How to get push key in firebase?
body: <p>I want to get the Key generated when I push data to Firebase database. I want to handle them with my own function,</p>
  
  <p>So the issue is when the user fills the form he sends the data to our real-time DB, contained in this data are some images (<strong>optional</strong>), and I don't need to let the image object empty in DB, so how to handle this, and when the user needs to send an image I want to save this image in the same Order, not in New Order. </p>
  
  <p>Node</p>
  
  <p><a href="https://i.stack.imgur.com/qKbus.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qKbus.png" alt="Node"></a></p>
  
  <p>Here is my function </p>
  
  <pre><code>handleOrder = () =&gt; {
      const { nameOfProblem, description, userId, imageOfPrblem, providerId } = this.state;
      const PushData = firebase.database().ref("request/" + providerId + "/" + userId + "/orders/");
      const ref = firebase.storage().ref("users/" + userId + "/UserImageOrders/" + path);
      let file = imageOfPrblem.uri;
      const path = "img_" + imageOfPrblem.fileName;
      var newOrderRef = PushData.push({
          nameOfProblem: nameOfProblem,
          description: description,
      });
      if (file) {
          let keyG = newOrderRef.key; // Key Generated with .push()
          PushData.child(keyG).update({ // didn't updated the key generated just add new element with new key !!
              imageOfPrblem: imageOfPrblem
          });
          ref.put(file).then(() =&gt; {
              console.log("File uploaded..")
          });
      }
  }
  
  handleImages = () =&gt; {
      const options = {
          title: "Select Images!",
          storageOptions: {
              skipBackup: true,
              path: "images"
          }
      };
      ImagePicker.showImagePicker(options, response =&gt; {
          console.log("Response = ", response);
          if (response.uri) {
              this.setState({ imageOfPrblem: response });
          }
          if (response.didCancel) {
              console.log("User cancelled image picker");
          } else if (response.error) {
              console.log("ImagePicker Error: ", response.error);
          } else if (response.customButton) {
              console.log("User tapped custom button: ", response.customButton);
              alert(response.customButton);
          }
      });
  };
  </code></pre>