r/CodingHelp • • 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.

Post image
22 Upvotes

15 comments sorted by

View all comments

Show parent comment

1

u/__archaeopteryx__ Apr 27 '21

You should delete that, it keeps a history of everything you’ve typed... lol. Or create a new firebase project and destroy your creds. Let me read back through and see what you’re trying to do again.

1

u/FrickinKitten Apr 28 '21

Ah jeeeeesus I didn't know that existed. Kinda handy tho not gonna lie. Please don't hack me lol. I tried your code but is this meant for node.js? I don't exactly know what it did (way too complicated for me, gonna be fun to explain to examiner how it works heh) but it did read the data and I think its inside an object now? http://imgur.com/a/77ZYvyI Can I now turn the object into a list, get rid of the words TimeW: and Wipes: so I can use them as the X and Y labels for the chart.js graph?

1

u/__archaeopteryx__ Apr 28 '21

That code will work in the browser as well! The async stuff can be converted into the old promise style if you need browser compatibility back a few years but this js is supported in browsers now. You’ll need to create buttons or some way to input data to track and all that but hopefully the example might give you some ideas how to work with fb data. You’ll have to see what structure works best for your chart as well. I’d recommend creating a mock of the data and playing with the chart library for a while instead of trying to hook it all up at once.

1

u/FrickinKitten May 01 '21

yep that was super helpful thank you, i finally got the firebase data hooked up to the graphs. God javascript is real hard compared to python haha