简体   繁体   English

错误:传入的参数必须是12字节的单个字符串或24个十六进制字符的字符串,它在mongodb和节点中

[英]Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters, its in mongodb and node

enter image description here I am trying to do a get request for each blog when they are clicked but for some reason its not working am getting an error.在此处输入图像描述我正在尝试在单击每个博客时对它们进行获取请求,但由于某种原因它无法正常工作,因此出现错误。 Here is my code.这是我的代码。

<% blogs.forEach(blog => { %>
  <a href="/blogs/ <%= blog._id %> ">
  <h3> <%= blog.title %>  </h3>
  <p> <%= blog.snippet %>  </p>
  </a>
<% }) %>

<div class="details content">
   <h2> <%= blog.title %>  </h2>
<div class="content">
   p> <%= blog.body %>  </p>
</div>
</div>

app.get('/blogs/:id', (req,res) => {
const id = req.params.id;
Blog.findById(id)
.then(result => {
res.render("details", {blog: result});
})
.catch(err => {
console.log("Error", err);
})
})

just try like this试试这样

const bodyParser = require('body-parser');
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: false}))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MongoDB, BSONTypeError: Argument pass in must be a string of 12 bytes or a string of 24 hex characters or an integer - MongoDB, BSONTypeError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer 传入的参数必须是 12 个字节的单个字符串还是 24 个十六进制字符的字符串? - Argument passed in must be a single String of 12 bytes or a string of 24 hex characters? 错误删除。 MongooDB + Express。 传入的参数必须是12个字节的单个字符串或24个十六进制字符的字符串 - Deleting with error. MongooDB + Express. Argument passed in must be a single String of 12 bytes or a string of 24 hex characters 我需要解决这个错误:BSONTypeError: Argument pass in must be a string of 12 bytes or a string of 24 hex characters or an integer - I need remedy of this error: BSONTypeError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer 在 node js / javascript 中使用 OR 条件时,传入的参数必须是 Buffer 或 12 个字节的字符串或 24 个十六进制字符的字符串 - Argument passed in must be a Buffer or string of 12 bytes or a string of 24 hex characters while using OR condition in node js / javascript TypeError:传入的参数必须是12个字节的字符串或24个十六进制字符的字符串 - TypeError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters 传入的参数必须是 12 个字节的字符串或 24 个十六进制字符的字符串或整数 - Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer BSONTypeError: 传入的参数必须是 12 个字节的字符串或 24 个十六进制字符的字符串 - BSONTypeError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters 传入的参数必须是 12 字节的字符串 - Argument passed in must be a string of 12 bytes 编码为十六进制字符串:参数必须是字符串node.js - Encode to hex string: argument must be a string node.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM