Upload the additional data only when the image upload is finished (sequence?)

Move the second call to inside the .then() function:

adatfeltolt() {
  this.mypicref.child(this.uid()).child('pic.jpg')
  .putString(this.picdata, 'base64', { contentType: 'image/jpg' })
  .then(savepic => {
    
    this.firebasedb.list("/fogasok/").push({
      datum:this.fogasDatuma,
      //halfaj:this.fogasHalfaj,
      suly:this.fogasSuly,
      egyeb:this.fogasEgyeb,
      keplink:savepic.downloadURL
    });
  })

}

Remember, almost EVERYTHING in JavaScript is asynchronous. I’m also doing some test migrating my stuff to async/await, worth the try, it’s a bit like this:

async adatfeltolt() {
  const savedPic = await  this.mypicref.child(this.uid()).child('pic.jpg')
    .putString(this.picdata, 'base64', { contentType: 'image/jpg' });

    this.firebasedb.list("/fogasok/")
    .push({
      datum:this.fogasDatuma,
      //halfaj:this.fogasHalfaj,
      suly:this.fogasSuly,
      egyeb:this.fogasEgyeb,
      keplink: savedPic.downloadURL
    });
}

Basically the await is telling it to wait until that is ready to move to the next line.

1 Like