7 Replies Latest reply: Jun 27, 2018 4:57 AM by Alexander Karlsson RSS

    Qliksense API - parallel asynchrounous data fetching using Promises

    Patric Amatulli

      Hi all,


      we have developed an extension and we have noticed that the extension are pretty slow during the data process fetching.
      We implemented a sequential data fetching process which takes approximately 20 seconds for fetching 60.000 rows (3 columns = 2 dimension + 1 measure).


      I was wondering if there is the possibility to use an asynchonous parallel data fetching mechanismus using promises using the backendapi from qlik.
      When I execute the code it raises always an exception when trying to load multiple requests at the same time, works fine when it is limited to 1 or 2.  Is this is a bug or it is simple not allowed to do it by the Qlik Engine?


      Any idea or hint would be very much appreciated :-) !


       function fetchData() {
            var columns = config.DATA_PER_ROW;  
            var totalheight = rowCount; 
            var pageheight = Math.floor(10000 / columns);  
            var numberOfPages = Math.ceil(totalheight / pageheight);  
            var qTotalData = [];
            var deferred = $.Deferred()
            var promises = Array.apply(null, Array(numberOfPages)).map(function(data, index) {  
                return backendApi.getData([{
                      qTop: (pageheight * index) + index,  
                      qLeft: 0,  
                      qWidth: columns,  
                      qHeight: pageheight,  
                      index: index  
            }, this);         
            Promise.all(promises).then(function(data) {  
              var qsData = data[0];
                  for (var j=0; j<qsData.length; j++) {  
                      for (var k=0; k<qsData[j].qMatrix.length; k++) {                                                  
            }).catch(function(error) { console.log(error)});   

      The code raises a general exception (undefined) :-/.