Skip to content

Fix TypeError on browser due to FormData #1092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

JSH32
Copy link

@JSH32 JSH32 commented Jun 19, 2022

Fixes #1000 and related to form-data/form-data#441

This replaces import FormData from 'form-data'; with import * as FormData from 'form-data';.
This removes the need for esModuleInterop and fixes a TypeError that happens on browsers shown below.

TypeError: form_data_1.default is not a constructor
    at getFormData (request.js?7d33:143:1)
    at eval (request.js?7d33:307:1)
    at step (request.js?7d33:44:1)
    at Object.eval [as next] (request.js?7d33:25:46)
    at eval (request.js?7d33:19:1)
    at new Promise (<anonymous>)
    at __awaiter (request.js?7d33:15:1)
    at eval (request.js?7d33:300:93)
    at eval (CancelablePromise.js?900e:80:1)
    at new Promise (<anonymous>)
    at new CancelablePromise (CancelablePromise.js?900e:46:1)
    at request (request.js?7d33:300:1)
    at AxiosHttpRequest.request (AxiosHttpRequest.js?b065:33:1)
    at FileService.upload (FileService.js?c60f:20:1)
    at eval (index.tsx?1953:75:33)
    at HTMLUnknownElement.callCallback (react-dom.development.js?ac89:4161:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js?ac89:4210:1)
    at invokeGuardedCallback (react-dom.development.js?ac89:4274:1)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js?ac89:4288:1)
    at executeDispatch (react-dom.development.js?ac89:9038:1)
    at processDispatchQueueItemsInOrder (react-dom.development.js?ac89:9070:1)
    at processDispatchQueue (react-dom.development.js?ac89:9083:1)
    at dispatchEventsForPlugins (react-dom.development.js?ac89:9094:1)
    at eval (react-dom.development.js?ac89:9285:1)
    at batchedUpdates$1 (react-dom.development.js?ac89:26096:1)
    at batchedUpdates (react-dom.development.js?ac89:3988:1)
    at dispatchEventForPluginEventSystem (react-dom.development.js?ac89:9284:1)
    at dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay (react-dom.development.js?ac89:6462:1)
    at dispatchEvent (react-dom.development.js?ac89:6454:1)
    at dispatchDiscreteEvent (react-dom.development.js?ac89:6427:1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is there a example of multipart/form-data request?
1 participant