Skip to content

Instantly share code, notes, and snippets.

@davideast
Last active April 20, 2021 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davideast/df32aea36d2d1475c041 to your computer and use it in GitHub Desktop.
Save davideast/df32aea36d2d1475c041 to your computer and use it in GitHub Desktop.
Push and return Firebase
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