0

I have the following code to grab data and view it in the console from a firebase setup, I have no idea why it isn't working. Here is my code below. It is running live at this site if you want to inspect it. Here is a link to a jsfiddle

<!doctype html>
<html lang="en" ng-app="DemoApp">
<head>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  <script type='text/javascript' src='https://cdn.firebase.com/js/client/1.0.11/firebase.js'></script>
   <script type="text/javascript">
var dataRef = new Firebase('https://edengarden.firebaseio.com/test');
dataRef.on('value', function(snapshot) {
  console.log(snapshot.val());
});
</script>
</head>
<body>
</body>
</html>
5
  • 2
    Your web site is not available. I suggest setting up a jsfiddle that reproduces your problem. Commented Apr 5, 2014 at 19:43
  • its up now at dev.anderskitson.ca no port numbers i updated above. but js fiddle is a good idea. Commented Apr 5, 2014 at 21:38
  • Now I get a syntax error on dev.anderskitson.ca/arduino/public_html. Just update the question when you have created the fiddle, we'll have a better chance of figuring it out. Commented Apr 6, 2014 at 0:54
  • Ok ive added the js fiddle link. Commented Apr 6, 2014 at 1:07
  • 1
    Your fiddle is listening for child_added, while the code in the question listens for value. Please make sure to have a single, consistent SCCE between them. But in general: listen for value on "regular" objects and listen for child_added when you have a list-like Firebase-ref, one that you push children to. I would recommend against mixing the two. Commented Apr 6, 2014 at 1:21

1 Answer 1

2

If I change your JavaScript to this:

var myDataRef = new Firebase('https://edengarden.firebaseio.com/test');
myDataRef.on('child_added', function(snapshot) {
    var message = snapshot.val();
    console.log(message);
});

It logs a lot of objects, like this:

Object {value: 11}

Object {value: 11}

Object {value: 11}

Object {value: 15}

...

Is that not what you see/expected?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.