【发布时间】:2021-09-07 22:11:03
【问题描述】:
我有一个包含一些 java 脚本对象的数组,我正在使用 ejs 来显示数据,但问题是 - 我必须在 req.params.id 的基础上过滤该数据并想要下一个 2 个数据对象..!过滤数据后——请帮忙
我的代码是 -
app.get("/:id", (req, res) => {
const requestParams = _.lowerCase(req.params.id);
let obj = blogData.find((o) => o.heading >= "Yoga-During-COVID");
console.log(obj);
blogData.forEach(function (post) {
const storedTitel = _.lowerCase(post.heading);
if (storedTitel === requestParams) {
res.render("blogfullDetail", {
date: post.date,
heading: post.heading,
subheading: post.subheading,
discription: post.discription,
discription2: post.discription2,
author: post.author,
authorImage: post.authorImage,
mainImg: post.mainImg,
});
}
});
});
数据文件-
【问题讨论】:
-
请do not post pictures of text,将该文本放入您的帖子中(使用适当的标记)。话虽如此,我不确定我是否理解您的需求,您能否(在您的帖子中)解释您拥有哪些数据,以及您希望代码做什么,以便获得您需要的数据(您在其中展示示例您拥有的数据,以及您需要成为的数据)。
-
我有一个对象数组,实际上我想过滤图片中的数据,过滤后需要的对象在 req.params.id 值 @Mike'Pomax'Kamermans 之后
-
请您解释一下in your post。再次,请用真实文本替换该图像。
标签: javascript node.js ejs