Last active
April 20, 2021 17:19
-
-
Save davideast/df32aea36d2d1475c041 to your computer and use it in GitHub Desktop.
Push and return Firebase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ref = new Firebase('<my-firebase-app>/items'); | |
// Create a push reference (no data has been sent to the server, just a generated id) | |
const childRef = ref.push(); | |
// create an object and with they push-id | |
const data = { name: 'David': key: childRef.key() }; | |
// save it | |
childRef.set(data); | |
// Listen for the update | |
childRef.on('value', (snap) => console.log(snap.val())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment