node js 에서 res.redirect같은 routing이 중복해서 일어날때 발생한다.
예를 들자면
export const getEditVideoController = async (req, res) => {
const {
params: {
videoId
}
} = req;
try{
const video = await Video.findById( videoId );
res.status(200);
res.render("editVideo", {pageTitle: `Edit ${video.title}`, video});
}catch(error){
res.status(400);
console.log(error);
res.redirect(routers.home);
}
res.render("editVideo", {pageTitle: `Edit ${video.title}`, video}); // 중복
};
위와 같은 경우에 발생한다.
export const getEditVideoController = async (req, res) => {
const {
params: {
videoId
}
} = req;
try{
const video = await Video.findById( videoId );
res.status(200);
res.render("editVideo", {pageTitle: `Edit ${video.title}`, video});
}catch(error){
res.status(400);
console.log(error);
res.redirect(routers.home);
}
};
으로 깔끔하게 고쳐주자.
'개발 > Web Programming' 카테고리의 다른 글
[JSP] Servlet과 JSP란? (0) | 2019.11.27 |
---|---|
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. (0) | 2019.11.24 |
multer 란? (0) | 2019.11.21 |
Pug template (0) | 2019.11.20 |
cannot read property 'trim' of undefined 에러? (0) | 2019.11.12 |