I'm trying to run the following code in react native(Expo):
import FormData from "form-data"; // installed with npm install 'form-data'
const formData = new FormData();
console.log(formData.getHeaders()); <------- formData.getHeaders is not a function. (In 'formData.getHeaders()', 'formData.getHeaders' is undefined)
But the only method that works is append.
getHeaders() works if I run the above code with node, but doesn't work in react native app.
Why doesn't it recognize the FormData methods such as getHeaders() or getBoundary()?
all you need is to replace the import line with this
import * as FormData from "form-data";
const formData = new FormData();
console.log(formData.getHeaders());