0
firebase.database().ref('people').child(this.state.ids[licznik]).child('login')

This is my query. However it does not work. this.state.ids[licznik] equals 1, and instead of it I put 1, '1' or variable without index (that is not in the table) that equals 1 everything works fine, but indexed one won't work. Is it possible to do it somehow? I need to do it with indexed one as this is inside of loop and licznik is being incremented

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
adammo
  • 171
  • 10
  • You can force the index to be a string like this: https://stackoverflow.com/questions/5765398/whats-the-best-way-to-convert-a-number-to-a-string-in-javascript – Diodeus - James MacFarlane Apr 30 '19 at 13:42
  • @Diodeus-JamesMacFarlane it's not working. Right now I have it like so: const myVar1 = this.state.ids[licznik]; const myVar2= myVar1+''; firebase.database().ref('people').child(myVar2).child('login') – adammo Apr 30 '19 at 13:58
  • We have no way to know what `this.state.ids[licznik]` is here. Please make sure the code you share is as standalone as possible. At best that allows us to quickly spot the problem, but otherwise we can run the standalone snippet on our own systems to reproduce your problem. – Frank van Puffelen Apr 30 '19 at 14:15

0 Answers0