question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use FormData in ES6 syntax?

See original GitHub issue

I have tried to run following code

import FormData from 'form-data'
...
const formData = new FormData();
formData.append('chart', chartfile)
...

Unfortunately, I get a error like below form_data_1.default is not a constructor

Let me know where the issue come from.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:14
  • Comments:5

github_iconTop GitHub Comments

41reactions
thazinwincommented, Apr 7, 2021

You would use as import * as FormData from 'form-data' to access all modules in a single variable.

6reactions
tyurin-ilyacommented, May 27, 2021

For me this is what worked: import { default as FormData } from "form-data";

Read more comments on GitHub >

github_iconTop Results From Across the Web

FormData - The Modern JavaScript Tutorial
FormData objects are used to capture HTML form and submit it using fetch or another network method. We can either create new FormData(form)...
Read more >
FormData() - Web APIs - MDN Web Docs - Mozilla
The FormData() constructor creates a new FormData object. Note: This feature is available in Web Workers. Syntax. new FormData() ...
Read more >
JavaScript FormData
Create a FormData object · First, select the submit button using the querySelector() method of the document object. · Next, add an event...
Read more >
What is a formData Object in JavaScript? - Educative.io
We created a FormData object using an empty FormData constructor. Then, we added some data in the form of name-value pairs using the...
Read more >
How to use FormData in node.js without Browser?
6 Answers 6 · 2. Thanks for your answer. · If its node js, you only can do var FormData = require('form-data'); Node...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found