-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
ReferenceError: FormData is not defined #5202
Comments
Seems like your runtime environment does not have/support FormData. Try to investigate this with window.FormData or global.FormData that depends on environment. Maybe this can help, but you need to provide some reproducible example, and only then someone can help you. |
Yeah, I agree that I should have something reproducible. I am trying in my local to replicate same if I can. I will go through the ref you have provided and see if anything positive comes out. :-) |
Seems like you runtime environment does not have/support FormData. Try to investigate this with window.FormData or global.FormData depends on environment. Maybe this can #4412 (comment), but you need to provide some reproducible example, and only then someone can help you. |
I am trying to reproduce the issue, so have created a small package to test , below is the code. Now, I am facing some kind of wired issue when trying to import axios. Have looked about the issue but does not seems to have exact root cause. Please let me know if you have any thought on this. Line, throws error - const axios_1 = __importDefault(require("axios")); // this is line give the warning which causing the issue I believe. Code https://github.com/ShaktiMandal/axios-fetch-api.git (axios - 1.0.0) |
@Romick2005 - actually I was trying to use this package in my code where I was Importing MakeAPICall from this package. Anyway, I found the solution for the original problem - ReferenceError: FormData is not defined. |
After doing some investigation, Came to know that main problem was due the testEnvironment i was using in Jest. Previously, I was using happy-dom /jest-environment and which cause the error. Issue got resolved after replacing it with jsdom. Just to summarize the solution if it help others. Please note, this might be one of the solution if encounter this issue. There could be other reasons which can cause same kind problem. Solution :
|
Closing the issue as it has been resolved. please refer to my previous comment for the solution if you encounter this issue. |
Describe the bug
Recently, In one of my vue3 project we have migrated vue-cli to vite. With vite, we are using jest for testing the component. After the migration, application run without any issue but I have started encountering below issue whenever running jest.
Reference Error: FormData is not defined (latest version - 1.1.3).
Please note that, I have started observing this error from version - 1.0..0.
Unfortunately, I wouldn't be able to share the code to reproduce the issue as its my client code. However, below is the high level structure.
We have the axios call in package which return response. Below is the code snippet causing the error.
import axios from "axios";
const instance = axios.create(); // this line is causing problem. If I comment out this line, issue disappear.
After some digging in axios code, it looks like source of the error is from lib/platform/browser/classes/ index
To Reproduce
No response
Code snippet
No response
Expected behavior
No response
Axios Version
1.0.0
Adapter Version
No response
Browser
chrome
Browser Version
No response
Node.js Version
above 14.19.0
OS
No response
Additional Library Versions
Additional context/Screenshots
The text was updated successfully, but these errors were encountered: