CopyPastor

Detecting plagiarism made easy.

Score: 0.907041085271183; Reported for: String similarity Open both answers

Possible Plagiarism

Reposted on 2019-05-12
by Frank van Puffelen

Original Post

Original - Posted on 2018-03-22
by Frank van Puffelen



            
Present in both answers; Present only in the new answer; Present only in the old answer;

When you execute a query against the Firebase Database, there will potentially be multiple results. So the snapshot contains a list of those results. Even if there is only a single result, the snapshot will contain a list of one result.
Your callback will need to handle that list by looping of the child nodes of the result with `forEach`. So something like:
this.firebase.database().ref('/requests') .orderByChild('-Lecn9gN5puugx5z-PKX/status').equalTo('Pending').on('value',(snapshot) => { snapshot.forEach((child) => { console.log(child.key+': '+child.val()); }) })
When you execute a query against the Firebase Database, there will potentially be multiple results. So the snapshot contains a list of those results. Even if there is only a single result, the snapshot will contain a list of one result.
Your code needs to cater for that list, by looping over `Snapshot.forEach()`:
imgRef.orderByChild('index').equalTo(leftInd).once('value', function(imageSnap){ imageSnap.forEach(function(child) { var image = child.child('url').val(); leftImg.src=image; }) })

        
Present in both answers; Present only in the new answer; Present only in the old answer;