javascript - ExpressJS/NodeJS:res.redirect 不工作
问题描述
我已经编写了用于检查用户是否存在的代码。在此基础上,我们使用 res.redirect 进行重定向。
app.post('/UserRegister', async (req, res, next) => {
const { username, password } = req.body;
const isTheir = await User.exists({ username: username});
console.log(isTheir);
if (isTheir==true) {
return next(new AppError("User Already Registered", 501));
}
const user = new User({username});
const registeredUser = await User.register(user, password);
console.log("Going to Search Flights");
res.redirect('/searchFlights');
});
似乎 res.redirect 不起作用,因为它不会 searchFlights 。请帮忙 。
解决方案
推荐阅读
- python-3.x - python - 如何将来自两个不同字典的数据帧连接成python中的新数据帧?
- binding - 如何通过 Binding 和 ObservedObject 更新 UIViewRepresentable 地图
- javascript - 带有两个函数调用的 onclick 需要两次单击才能运行两个函数 js
- php - 社交网站的评论通知
- java - SonarQube 未在 javadoc 中显示错误
- python - PythonQT、QMenu 更新 QActions
- javascript - 我得到了一个带有 JS、HTML 和 CSS3 的代码片段。如何将它插入到 wordpress html-widget?
- r - 将 Excel 数字日期转换为 R 日期,但在某些行中只有给出的年份,例如“2018”而不是“43465”
- multithreading - 用mkldnn编译mxnet CPP包,支持单线程执行,无需环境变量
- javascript - 如何多查找聚合