0
파일을 구문 분석하고 req에 추가하기 위해 간단한 고속 미들웨어를 작성했습니다. 이 모양입니다. 'formidable'에서 import formidable;다음 호출에도 불구하고 익스프레스 미들웨어에 왼쪽 교수형 요청
export const parseForm = (req, res, next) => {
const form = new formidable.IncomingForm();
form.parse(req, (err, fields, files) => {
if(err) {
next(err);
}
req.files = files; // eslint-disable-line
next();
});
};
(다른 미들웨어와 함께)이 앱에 추가 할 예정입니다.
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cors());
app.use(parseForm);
// static paths
const publicPath = express.static(path.join(__dirname, '../client/public'));
app.use(publicPath);
// routes
app.use('/api', adminRoutes);
app.use('/api', ingredientRoutes);
app.use('/api', productRoutes);
내 문제는 미들웨어에서 다음 함수를 호출 함에도 불구하고 내 요청이 정지 상태입니다. 다음에 몇 가지 주장을 전달하기로되어 있습니까? 아니면 아마도 미들웨어를 잘못된 방식으로 전달하고 있습니까?
도움 주셔서 감사합니다.