我要保存用户(检查所有信息是否正确),然后上传图片 请帮忙吗?
app.post('/users', upload, (req, res) => {
if (req.fileError) {
return res.send(req.fileError)
}
let body = _.pick(req.body, ['email', 'password']);
if(req.file)
body.avatar = req.file.filename;
const user = new User(body);
user.save().then((user) => {
return user.generateAuthToken();
}).then((token) => {
res.header('x-auth', token).send(user);
}).catch((e) => {
res.status(400).send(e);
})
})``