req.files does not exist on request
I am getting this error when trying to upload a file
server\server.ts(31,19): error TS2339: Property 'files' does not exist on type 'Request'.
I can do (res.send(req['files'])); and it works,.. but not on (res.send(req.files));
app.post("/upload", multer({dest: "./uploads/"}).array("uploads", 12), function(req, res) {
//(res.send(req['files']));
(res.send(req.files));
});
Are you using the multer definition file?
How can I Check? I just installed multer through NPM. Sorry fairly new to this.
Hmm, I actually am not that familiar with how TypeScript works. But I believe that you have to add some kind of definition file since multer is written in ordinary javascript.
Seems like maybe this is it: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/multer/multer.d.ts
Worked like a charm. Thanks a lot. I just took the file and placed it on the node server and referenced to the correct location of express.d.ts
Glad to hear it 🙌
@LinusU link broken
new link: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/multer/index.d.ts