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

Asked 1 years ago, Updated 1 years ago, 61 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.