When retrieving the req.body element in node.js+express

Asked 2 years ago, Updated 2 years ago, 80 views

I am trying to get the Json type data put during node+express from req.body and output the log.

JSON.stringify (req.body)

So how do we stop __prot__ from being deleted or included in the data?

javascript node.js

2022-09-30 21:21

1 Answers

JSON.stringify() How about using the second argument of the function?

JSON.stringify(req.body,(key,value)=>key==="__prot__"?undefined:value)

Note: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify


2022-09-30 21:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.