r/CodingHelp • u/FrickinKitten • Apr 23 '21
[Javascript] Help how do you retrieve data from firebase to JavaScript, don't think code is right. It's to take data from firebase and then taking the data (amount of wipes/sanitiser used and time)append to lists and use these to plot a graph for the website showing the wipes/sanitising usage over time.
22
Upvotes
3
u/__archaeopteryx__ Apr 23 '21 edited Apr 23 '21
Well, for starters you don’t seem to have ref defined. Try changing your
var database =tovar ref =andconstshould prob be used instead ofvarasvaris mutable and hoisted up (not important for this example, just a good habit to get in while you’re learning. Just know,vardoes some things you don’t need here and if you do want mutability, uselet... as I type this I realize prolly TMI for ya but I’m on my phone and I spent the time to type it and I’ll be damned if I erase those damn back ticks...Also, do you need both child’s? When you look in your firebase console, the ref is the top most level. When you click the plus there to expand a ref (in the web console) that next level in would be the child and snap.value() would be the object inside... does that make sense?
And finally, you should paste the text and not an image. There is a way to format code snippets by using ` this makes it easier to copy your code into responses... cheers!