I keep getting the error in the title and cant figure out why.
I have painful quest to generate multiple (5-10) pdf files at once, and send all of them to my server.
when i click button, it will trigger this for loop which generates rows and colums as arrays. To be send to jsPDF
uploadMultipleContracts = (e) => {
let pdf = []
const columns = [
{ title: 'Date', dataKey: 'date' },
{ title: 'User', dataKey: 'user' },
....
]
const rows = []
for (let i = 0; i < this.state.multipleDetailContract.length; i += 1) {
rows.push({
date: this.state.multipleDetailContract[i].date,
user: this.state.multipleDetailContract[i].user,
....
})
if(e.target.name === "save"){
pdf.push(this.sendMultiPDF(columns, rows));
}
}
console.log(pdf)
this.pdfSender(pdf)
};
Then we push return value (pdf file from this.sendMultiPDF(columns, rows)
) into array of pdf's let pdf = []
after this the console.log()
will print array of chosen PDF files, it looks just as you would expect, 5-10 objects in array, all look like proper PDF.
then we send this array set to this.pdfSender(pdf)
which has axios in it
pdfSender = (data) => {
axios.post(`${process.env.API_URL + process.env.API_PORT}api/test`,
data,
{
responseType: 'arraybuffer',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/pdf'
}
})
.then(function () {
console.log('SUCCESS!!');
})
.catch(function (error) {
console.log(error);
})
};
but pdfSender will catch and throw error TypeError: "cyclic object value"
All google did provide is some explanation of object refering to itself. I dont know, or cant figure how that would be the case.
multipleDetailContract:
{
"contractid" : "xxxx",
"user" : "xxxxxx",
"date" : 12-03-18,
"hasUpperLimit" : "true",
"alert" : null,
"fees" : yyyyy
}