0
votes
 (function(){
     const preObj=document.getElementById('object');




     const preObjRef = firebase.database().ref().child('object');

     preObjRef.on('value', snap => console.log(snap.val())); 

 }());

I followed exactly some learning videos, but still receive this error...

the error in this line of code:
preObjRef.on('value', snap => console.log(snap.val()));

error text:

Uncaught SyntaxError: missing ) after argument list

1
Post a bit more of your code please! The code you posted actually has one ) too much... - sandrooco
you can see the attached image.. - EL Yabany
Try this: snap => { console.log(snap.val()) } ) 1. Don't show us your firebase config. 2. Don't EVER post code as picture - always post it in the question (copy&paste?!) - sandrooco
for security ,I know ,but I just try for just learing and i have no previouse experience in asking here.. - EL Yabany
I just tried your solution but no thing happened! - EL Yabany

1 Answers

1
votes

My guess is that you're running this code in an environment that doesn't understand the ES6 fat-arrow syntax. In that case you can replace it with:

preObjRef.on('value', function(snap) { console.log(snap.val()); }); 

I'd also consider upgrading the environment where you run the code, because more and more systems assume ES6 support.