I was facing this tiny issue in a sample NodeJS application I was creating, that I always receive req.files
as undefined even though I am uploading a file via postman.
Here's the code:
import express from 'express';
import http from 'http';
let app = express();
app.post('/', function(req, res) {
let files = req.files;
res.send(files);
})
app.listen(process.env.PORT || 8000, () => {
console.log(`Started on port 8000`);
});
export default app;
And here's how I am sending the file via postman:
But I still get and empty response and also as logging on cmd I get the output as undefined:
Would be greatful if anyone could help.