我在第 14 行出现 undefined
错误,req.file
:
import { Request, Response } from 'express'
import path from 'path'
import Photo from '../models/Photo';
export function getPhoto(req: Request, res: Response){
}
export async function createPhoto(req: Request, res: Response) {
const {title, description} = req.body;
const newPhoto = {
title: title,
description: description,
imagePath: req.file.path
};
const photo = new Photo(newPhoto);
await photo.save();
return res.json({
message: 'Foto creada correctamente',
photo
})
}
我的 github 上的更多代码:link
我该如何解决?