this is the problem.
I want to use realtime database with firebase and this problem is preventing me.
I think I’m using the old technique.
this is the problem.
I want to use realtime database with firebase and this problem is preventing me.
I think I’m using the old technique.
2
Answers
The code snippet in the image shows an older way to connect to Firebase Realtime Database.
Here’s what you can do to update it:
Create a DatabaseReference:
Get a reference to the location in your database where you want to store or retrieve data:
Replace "path/to/your/data" with the actual path to your desired location.
Write data to the database:
Use the set method on the DatabaseReference to write data:
Read data from the database:
Use the once method to get a snapshot of the data at a specific point in time:
From the documentation of
reference
:So, use
ref()
instead ofreference
.This exact use-case is also covered in the documentation on getting a database reference.