The problem of the value of function

dataApi:function(callback){
                var datax = [];
                this.getApi(function(data){
                    data.subjectCategorys.forEach(function(el){
                        var CategoryId = el.subjectCategoryId;
                        this.startIndex = 0;
                        this.pageSize = 20;
                        this.subjectId = el.subjectId;
                        var params = {startIndex:this.startIndex,pageSize:this.pageSize,subjectId:this.subjectId,subjectCategoryId:CategoryId}
                        huiguPost(function(data){
                            if(data.code == 0){
                                callback&&callback(data.data);
                            }else{
                                utils.Errordata();
                            }
                        },"http://develop.huiguqx.com/thirdpartyapi/subject/querySubjectArticles", params);
                        datax.push(el.subjectCategoryId);
                    })
                });
            },

how do I get the value of datax in dataApi when I want to get it outside?

Apr.02,2021

I see you define callback, and you can pass it to your callback

Menu