从查询中的回调中获取数据

时间:2017-08-28 18:45:29

标签: javascript parse-platform react-native parse-server

我正在尝试从查询中的查询中获取数据。我尝试了一切都没有成功。

getvideos() {
            var sectionHolder = [];
            var ids = [];
            var titles = [];
            var videos = [];
            var challengeCl = Parse.Object.extend("Challenges");
            var query = new Parse.Query(challengeCl);

                query.find().then((data) => {

                    for(var key = 0; key < data.length; key++) {
                        var object = data[key];
                        var videoid = object.id;
                        var title =  object.get('title');
                        ids.push(videoid)
                        titles.push(title)
                            var video = Parse.Object.extend('Videos');
                            var queryv = new Parse.Query(video);
                                queryv.equalTo('challengeid', videoid);
                                queryv.find().then( 
                                    (video) => { 
                                        videos.push(video); //i want to get this data out from this scope
                                });

                                sectionHolder.push({title: title, data: videos}); // <---- i want to put videos data in data 
                    } 
                    console.log(sectionHolder);
                    this.setState({listData: sectionHolder});
                });
}

我阅读了解析文档,但没有任何相关内容。

0 个答案:

没有答案