Skip to content
Advertisement

How do i use a variable in firebase storage ref

I have built a function to get the download URL for the specified ref which can be found below:

JavaScript

EDIT:

JavaScript

EDIT : This code above this generates html, i made it so it makes a title on the button, when clicked it grabs the buttons title value, and then it passes that (val) variable to that function above, and then goes from there

And Basically when i use the example above it wrks just fine… but when i use a variable called (value) it tells me that there is a 404 file doesnt exist… but when i look at the (value) variable and the original ref that i typed into the function… there the exact same why isnt it working? Why cant i use the variable?

Advertisement

Answer

The problem is that this.tile in onclick="download_file(this.title)" is evaluated when the user clicks the element, and at that point this is a different object. The easiest way to fix this is to inject the correct value into the childData.DownloadName immediately when you render the HTML:

JavaScript
Advertisement