So I am using react-pdf/renderer to generate a pdf on React client side. Now when the user presses a button, the generated file should be sent to the server as a file.
Now I am using pdf provided by the react-pdf/renderer
setFile(pdf(<PdfReport/>))
this gives the error cannot convert object to primitive types when I append this file to formdata. I converted this file to blob and then to a file
setFile(pdf(<PdfReport/>).toBlob());
var pdf = new File([file], "filename");
and when I send this to the server, I get a pdf file with only this
[object Promise]
I don't know how to convert the pdf generated to file to be able to send to server.