javascript - Uncaught TypeError in jsPdf autotable -


am trying print dynamic data's pdf file using jspdf auto-table . when doing got kind of error's like

the headers should object or array, is: function (jspdf.plugin.autotable.js:10 )

the data should object or array, is: function        (jspdf.plugin.autotable.js:10)  typeerror: t.foreach not function     (angular.js:12314) 

here code ,

            var getcolumns = function () {                  	    return [                  	        {title: "id", datakey: "id"},                  	        {title: "name", datakey: "first_name"},                  	        {title: "email", datakey: "email"},                  	        {title: "city", datakey: "city"},                  	        {title: "country", datakey: "country"},                  	        {title: "expenses", datakey: "expenses"}                  	    ];                  	};                  	function getdata(mainsteps) {                  	    mainsteps = mainsteps || 4;                  	    //var sentence = faker.lorem.words(12);                  	    var data = [];                  	    (var j = 1; j <= rowcount; j++) {                  	        data.push({                  	            id: j,                  	            first_name: this.getsteps(),                  	            email: this.getsteps(),                  	            country: this.getsteps(),                  	            city: this.getsteps()(),                  	            expenses: this.getsteps()                  	           // text: shufflesentence(sentence),                  	            //text2: shufflesentence(sentence)                  	        });                  	    }                  	    return data;                  	}                  var pdfsize='a4';                 var doc = new jspdf('p', 'pt',pdfsize);                         doc.autotable(getcolumns, getdata, {                  	theme: 'grid', // 'striped', 'grid' or 'plain'                  	headerstyles: {                          fillcolor: [12, 234, 227],                          textcolor: [12, 1, 1]                      },                     // margin: { top: 50, left: 20, right: 20, bottom: 0 },                  	styles: {                  	      overflow: 'linebreak',                  	      columnwidth: 88                  	    },                  	    beforepagecontent: function(data) {                  	    	                  	        doc.text("process name :"+maindata.name+"  ||   "+"description :"+maindata.description, 40, 30);                  	                          	    },                  	    //starty: doc.autotableendposy() + 20,                      columnstyles: {                        0: {columnwidth: 200}                      }                    });                  //starty: doc.autotableendposy() + 20                    doc.save(maindata.name+".pdf");              }          };
note : if error in code mean's can find solution , says error in (jspdf.plugin.autotable.js:10 ) , (angular.js:12314) getting confused here . can clarify me pls .

as errors explain input data must arrays or objects. in case means calling functions instead of sending them autotable. replace

doc.autotable(getcolumns, getdata, {...});

with

doc.autotable(getcolumns(), getdata(), {...});


Comments