老师你好,第3.7节,加入asyncBootstrap后,server端无法调试通过,3.7节14分钟之前的课程调试都没有问题,本次报错如下,谢谢!
(node:40547) UnhandledPromiseRejectionWarning: TypeError: asyncBootstrap is not a function
at getTemplate.then.template (/Applications/XAMPP/xamppfiles/htdocs/stydyreact22/server/util/dev-static.js:49:7)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:40547) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:40547) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
dev-static的代码如下:
module.exports = function (app) {
app.use('/public',proxy({
target: 'http://0.0.0.0:5577'
}))
app.get('*',function (req,res) {
getTemplate().then(template => {
const routerContext = {}
const app = serverBundle(createStoreMap(), routerContext, req.url)
asyncBootstrap(app).then(() => {
if(routerContext.url) {
res.status(302).setHeader('Location',routerContext.url)
res.end()
return
}
const content = ReactDomServer.renderToString(app)
res.send(template.replace('<!-- app -->',content))
})
})
})
}