Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
How to avoid Cannot read property 'toString' of undefined in Javascript

I'd like to use my easyinvoice npm package to locally store the pdf that I will create.

And two of values in my JSON data that I will post contain empty value as below (company, custom2)

{   company: '',   address: 'Address 1',   zip: '1010',   city: 'DonorCity',   country: 'DonorCountry',   custom1: 1664104,   custom2: '',   custom3: 'Smith@gmail.com' }

Then I copy and pasted the easyinvoice npm package code from "To store the file locally (NodeJS)" block as below

const result = await easyinvoice.createInvoice(data);
await fs.writeFileSync("invoice.pdf", result.pdf, 'base64');

And now when I run this with my node.js, it gives an error saying they cannot read property 'toString' of undefined

{
  error: 'TypeError',
  message: "Cannot read property 'toString' of undefined",
  errorId: 'db27502f6b12474eb59a28892bea555d'
}

node:internal/process/esm_loader:94
    internalBinding('errors').triggerUncaughtException(
                              ^
{
  error: 'TypeError',
  message: "Cannot read property 'toString' of undefined",
  errorId: 'db27502f6b12474eb59a28892bea555d'
}

I am not sure how to resolve this error? Any help will be appreciated thank you heaps!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!