function callNext (nextIndex) {
                        getNextChunk(nextIndex)
                            .then(function () {
                                return getNextIndex(nextIndex)
                                    .then(function (nextNext) {
                                        if (nextNext) {
                                            callNext(nextNext);
                                        } else {
                                            var b = new Blob([totalText], {type: 'text/csv;charset=utf-8'});
                                            saveAs(b, scope.filename + '.csv');
                                        }
                                    });
                            });
                    }
// The second one to take the next index
The second one to take the next index
The second one to take the next index
function callNext (nextIndex) {
                        getNextChunk(nextIndex)
                            .then(function () {
                                return getNextIndex(nextIndex)
                                    .then(function (nextNext) {
                                        if (nextNext) {
                                            callNext(nextNext);
                                        } else {
                                            var b = new Blob([totalText], {type: 'text/csv;charset=utf-8'});
                                            saveAs(b, scope.filename + '.csv');
                                        }
                                    });
                            });
                    }
function callNext ( nextIndex ) { getNextChunk ( nextIndex ) . then ( function ( ) { return getNextIndex ( nextIndex ) . then ( function ( nextNext ) { if ( nextNext ) { callNext ( nextNext ) ; } else { var b = new Blob ( [ totalText ] , { type : 'text/csv;charset=utf-8' } ) ; saveAs ( b , scope . filename + '.csv' ) ; } } ) ; } ) ; }
The second one to take the next index
The second one to take the next index