cer*_*lex 1 node.js firebase google-cloud-functions
自从将Firebase的Cloud Functions升级到Node8和ES17以来,在尝试更新功能时出现TsLint错误。它抛出Promises must be handled appropriately以下代码:
app.get('*', (req, res) => {
const isBot = detectBot(req.headers['user-agent']);
if (isBot) {
const botUrl = generateUrl(req);
// If bot, fetch url via rendertron
fetch(`https://foo.com/render/${botUrl}`)
.then(rendertronRes => rendertronRes.text())
.then(body => {
res.set('Cache-Control', 'public, max-age=300, s-maxage=600');
res.set('Vary', 'User-Agent');
res.send(body.toString());
});
} else {
// Not a bot, fetch the regular Angular app
fetch('https://bar.com/')
.then(regularRes => regularRes.text())
.then(body => {
res.send(body.toString());
})
.catch(err => res.send(err));
}
});
Run Code Online (Sandbox Code Playgroud)
最奇怪的部分是它抱怨第二次获取,而不是第一次获取。
| 归档时间: |
|
| 查看次数: |
929 次 |
| 最近记录: |