Error: Route.get() requires a callback function but got a [object Promise]
Error: Route.get() requires a callback function but got a [object Promise]
你们是我最后的希望,我花了12个多小时都没能解决问题
应用程序功能齐全,直到我进行了修改并添加了控件
并将露营地路线移动到单独的文件“controllers”以制作这样的路由器文件
router.get("/", isLoggedIn, CatchAsync(Campgrounds.index));
router.get("/me", isLoggedIn, CatchAsync(Campgrounds.me));
router.get("/new", isLoggedIn, CatchAsync(Campgrounds.new_camp));
router.post("/new/submit", isLoggedIn, validate, CatchAsync(Campgrounds.submitnew));
router.get("/:id", isLoggedIn, CatchAsync(Campgrounds.show_Camp));
router.get("/:id/edit", isLoggedIn, isAuthenticated, CatchAsync(Campgrounds.edit_Camp));
router.delete("/:id/delete", isLoggedIn, isAuthenticated, CatchAsync(Campgrounds.delete_Camp));
之后申请失败运行
Error: Route.get() requires a callback function but got a [object Promise]
这里是沙盒上的项目https://codesandbox.io/s/vigorous-galileo-sdy0w?file=/app.js
那 Error
告诉你一切。我看到了你的沙箱,它显示:
(alias) CatchAsync(fn: any): Promise<(req: any, res: any, next: any) => void>
你的 CatchAsync
函数 returns 一个承诺和 Route.get() 需要回调。
你应该知道 async function
是什么意思。
来自文档:
The word “async” before a function means one simple thing: a function always returns a promise. Other values are wrapped in a resolved promise automatically.
你们是我最后的希望,我花了12个多小时都没能解决问题
应用程序功能齐全,直到我进行了修改并添加了控件
并将露营地路线移动到单独的文件“controllers”以制作这样的路由器文件
router.get("/", isLoggedIn, CatchAsync(Campgrounds.index));
router.get("/me", isLoggedIn, CatchAsync(Campgrounds.me));
router.get("/new", isLoggedIn, CatchAsync(Campgrounds.new_camp));
router.post("/new/submit", isLoggedIn, validate, CatchAsync(Campgrounds.submitnew));
router.get("/:id", isLoggedIn, CatchAsync(Campgrounds.show_Camp));
router.get("/:id/edit", isLoggedIn, isAuthenticated, CatchAsync(Campgrounds.edit_Camp));
router.delete("/:id/delete", isLoggedIn, isAuthenticated, CatchAsync(Campgrounds.delete_Camp));
之后申请失败运行
Error: Route.get() requires a callback function but got a [object Promise]
这里是沙盒上的项目https://codesandbox.io/s/vigorous-galileo-sdy0w?file=/app.js
那 Error
告诉你一切。我看到了你的沙箱,它显示:
(alias) CatchAsync(fn: any): Promise<(req: any, res: any, next: any) => void>
你的 CatchAsync
函数 returns 一个承诺和 Route.get() 需要回调。
你应该知道 async function
是什么意思。
来自文档:
The word “async” before a function means one simple thing: a function always returns a promise. Other values are wrapped in a resolved promise automatically.