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.

require("form-data") returns undefined in Safari in webworker

See original GitHub issue

When executing the following code:

var FormData = require("form-data");
var formData = new FormData();

I see the following error in the console output:

[Error] TypeError: undefined is not a constructor (evaluating 'new FormData()')

This code works fine in Firefox + Chrome.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Ockejanssencommented, Nov 14, 2018

Just had the problem with the request module (browserifyed version) 😉 They use methods which doessn’t exist in the browser. But that another issue 😃

0reactions
alexindigocommented, Nov 13, 2018

That’s the goal, since node-form-data only works in nodejs. And browser has built-in functionality.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FormData in a webworker - in some browsers - is this wrong?
However, in Safari and Firefox, I get FormData is undefined. I found out that this is fine and to be expected: as mentioned...
Read more >
Shiming Request.formData in Safari - Paul Kinlan
When reading the request data that is posted by the user from a Form, you can use the event.request.formData() method to get a...
Read more >
Safari Technology Preview Release Notes
formData () to not reject the promise if the body is null and the MIME type ... or port if its host is...
Read more >
Web Workers API - Web APIs - MDN Web Docs - Mozilla
Web Workers makes it possible to run a script operation in a background thread separate from the main execution thread of a web...
Read more >
Web worker - Wikipedia
A web worker, as defined by the World Wide Web Consortium (W3C) and the Web Hypertext Application Technology Working Group (WHATWG), is a...
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