Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object not a function, on jspdf invocation

I have borrowed the code from here and I am trying to make it work as a proof of concept in my React application.One of the issues I encounter is with line:

var pdf = new jspdf('p', 'pt', 'letter');

In such case I get the following error: TypeError: WEBPACK_IMPORTED_MODULE_2_jspdf.jspdf is not a constructor

If I remove 'new' var pdf = jspdf('p', 'pt', 'letter');

I am getting the error: TypeError: Object(...) is not a function

What am I doing wrong. It seems like it is working in all examples, but no in my editor :)

like image 447
py_script Avatar asked Nov 07 '22 16:11

py_script


1 Answers

It's a typo

const jsPDF = require('jspdf')
var pdf = new jsPDF('p', 'pt', 'letter')
like image 193
AthMav Avatar answered Nov 14 '22 21:11

AthMav