Below is my sample response that I getting from the backend.
let data = [
{
"thisIsTheResponseFromBackEnd": [
{
"Col Header 1": "AAA, AAA",
"Col Header 2": "BCD",
"Col Header 3": "dummy data 1",
},
{
"Col Header 1": "BBB, BBB",
"Col Header 2": "BCD",
"Col Header 3": "dummy data 1",
},
{
"Col Header 1": "Hello,world",
"Col Header 2": "BCD",
"Col Header 3": "dummy data 1",
}]
}]
am trying to push dynamic data into jspdf autoTable. i use header: Object.keys(data[0]) //as column
but if try to push the value of the object it returns only [object, Object]
I tried below possible ways to push data into the body of jspdfatuoTable. but failed the below approach.
/* Object.keys( data ).forEach( key => {
console.log( data[key] );
const temp = [data[key]];
rows.push(temp);
console.log('body ?', rows);
}); */
/* Object.keys(data).forEach(function (prop) {
const temp = [data[prop]];
rows.push(temp);
}); */
for (let [key, value] of Object.entries(data)) {
const temp = [data.value];
rows.push(temp);
console.log('body ?', rows);
}
Could someone help me with this?
Thank you
Header: Object.keys(data[0])[0]
Body: data.map(x => Object.values(x))