These are chat archives for angular/angular-2-ionic-2

1st
Oct 2018
Alexandre R.
@Talents_finder_twitter
Oct 01 2018 19:04

Hi, I have this kind of data in firebase :
Offers :
I-----------Offer1:
I--------Price: 10
I--------Type: 'Car'
I-----------Offer2:
I--------Price: 5
I--------Type: 'Fruits'

I'm getting the data with this :
firebase.database().ref('offers').child('offer1').once('value', (snapshot) => {
snapshot.forEach((childSnapShot) => {
var offerKey = childSnapShot.key
var offerData = childSnapShot.val()
})
})
I'm trying to push these data into an array by doing this :
this.offers.push({'offer1': {[offerKey]:offerData}})

But I get this kind of result :
{'offer1': {'price': 10'}}
{'offer1': {'type': 'car'}}

Instead of this :
{'offer1': {'price': 10, 'type': 'car'}}

What I'm doing wrong.