在名为 click=click11 的 EJS 文件中创建了一个 cookie。我想每当有人访问 url 时首先检查 cookie 是否存在。如果它在那里呈现一个页面,如果它不在那里呈现不同的页面。
这是我的代码!如果 cookie 存在,我想渲染它。否则发送错误。如何实施?
router.get('/:uuid_d', async (req, res) => {
const file = await File.findOne({});
const user = await User.findOne({});
if(!file) {
return res.render('download'});
}
const response = await file.save();
const response2 = await user.save();
const filePath = `${__dirname}/../${file.path}`;
res.download(filePath);
});