Axios Formdata() Getting Empty Object
Browser-side code let data = new FormData(); data.append('file', file); data.append('userId', userId); axios.post(`${baseUrl}/uploadFile`, data, {headers: {'Content-Type':'multi
Solution 1:
You are sending multipart/form-data
encoded data.
You have:
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
i.e.
- A decoder for URL encoded data
- A decoder for JSON encoded data
You don't have one for Multipart encoded data!
Now, since you are using it, see the documentation for body parser:
This does not handle multipart bodies, due to their complex and typically large nature. For multipart bodies, you may be interested in the following modules:
- busboy and connect-busboy
- multiparty and connect-multiparty
- formidable
- multer
Post a Comment for "Axios Formdata() Getting Empty Object"