Cant get the middleware work in express 4
See original GitHub issueI am just following the readme tutorial and encountered the problem of
Error: Unexpected field
at makeError (*\node_modules\multer\lib\make-error.js:12:13)
my code look like this:
var express = require('express');
var app = express();
var multer = require('multer');
var upload = multer({ dest: './uploads/'});
app.post('/image',upload.single('avatar'), function (req, res) {
var image = req.body;
res.status(204).end()
});
my client is angular from the tutorial :https://uncorkedstudios.com/blog/multipartformdata-file-upload-with-angularjs
I cant find the solution can you help me?
Issue Analytics
- State:
- Created 8 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Node / Express 4 middleware not working - Stack Overflow
An important thing to know about Express middleware is that it's called in order of declaration. If any of the declared middleware handles...
Read more >Writing middleware for use in Express apps
Middleware functions are functions that have access to the request object ( req ), the response object ( res ), and the next...
Read more >Complete Guide to Express Middleware - Reflectoring
We can use middleware functions for different types of processing tasks required for fulfilling the request like database querying, making API ...
Read more >Express/Node introduction - Learn web development | MDN
You can use Express middleware to add support for cookies, sessions, and users, getting POST / GET parameters, etc.
Read more >Handle GET and POST Request in Express - CodeForGeek
GET and POST is two common HTTP Requests used for building REST APIs. ... Express requires an additional middleware module to extract incoming...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What is the field name of the file uploaded?
<input type="file" name="THISVALUE" />
The code you are using is expecting it to be
avatar
.Got it. I was using ng2-file-upload to send the XHR request. By default they set the name of all the fields to
file
.