如何合并到从Firebase检索的数组

时间:2019-01-24 14:42:24

标签: reactjs firebase react-redux

我从firebase中检索了数据...但是只检索了子表数据...我想从所有子表中检索所有数据...

    var ref = fire.database().ref('Employers/');
     ref.on("child_added", (snapshot) => {
             let slidercontents = snapshot.val()

             let newState = [];
                 for (let item in slidercontents) {
                 newState.push({
                     id: item,
                     title: slidercontents[item].Title,
                     description: slidercontents[item].Description,
                     location: slidercontents[item].Location,
                     rateperhour: slidercontents[item].RatePerHour
                 });
                 }
                 this.setState({
                     slidercontents: newState
                 });       
    });

0 个答案:

没有答案