Skip to content

Instantly share code, notes, and snippets.

@rdallaire
Created December 10, 2014 01:16
Show Gist options
  • Save rdallaire/35092654b95dc7c67e83 to your computer and use it in GitHub Desktop.
Save rdallaire/35092654b95dc7c67e83 to your computer and use it in GitHub Desktop.
firebase get data
<script src='https://cdn.firebase.com/js/client/2.0.4/firebase.js'></script>
<script>
// var fb = new Firebase("https://sizzling-heat-3015.firebaseio.com/");
// fb.set({ name: "Alex bob" });
// fb.on("value", function(data) {
// var name = data.val() ? data.val().name : "";
// alert("My name is " + name);
// Get a reference to our posts
var ref = new Firebase("https://docs-examples.firebaseio.com/web/saving-data/fireblog/posts");
// Attach an asynchronous callback to read the data at our posts reference
ref.on("value", function(snapshot) {
console.log(snapshot.val());
}, function (errorObject) {
console.log("The read failed: " + errorObject.code);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment