This does not handle multipart bodies, due to their complex and typically large nature […]
routes.post('',
upload.single('file'),
(req, res, next) => {
next(req.file ? null : new Error('No file!'));
},
(req, res) => {
res.json({ id: req.categoryId });
}
);
routes.post('',
(req, res, next) => {
upload.single('file')(req, res, (err) => {
if (err) return next(err);
if (!req.file) return next(new Error('No file!'));
next();
});
},
(req, res) => {
res.json({ id: req.categoryId });
}
);
address
. Вообще-то в сообщении об ошибке обычно есть имя файла и номер строки. obj.address = ...
// в контексте модулей
this === exports // true
this === module.exports // true
app.param('userId', (req, res, next) => {
// тут какой-то длинный код
next();
});
app.get('/users/:userId', (req, res) => { ... });
app.get('/users/:userId/info', (req, res) => { ... });
app.post('/users/:userId', (req, res) => { ... });
add_header 'Access-Control-Allow-Credentials' 'true' always;