I'm new to js, I see this a lot in the code I'm reading
_.pick(req.body, ' ' , ' ')
What does req.body do? And when can I say req.body.something?
I'm new to js, I see this a lot in the code I'm reading
_.pick(req.body, ' ' , ' ')
What does req.body do? And when can I say req.body.something?
req.body
holds parameters that are sent up from the client as part of a POST request. See the API.
// POST user[name]=tobi&user[email]=tobi@learnboost.com
req.body.user.name
// => "tobi"
req.body.user.email
// => "tobi@learnboost.com"
// POST { "name": "tobi" }
req.body.name
// => "tobi"
(req.body, ' ' , ' ') --> here req is the parameter of your function and using this parameter your can access the properties over then url.
so look this example
suppose this is form
<form>
enter the name : <input type="text" name="name">
<button type ="submit"> submit </button>
</form>
so if you want to access the name -- which is filled by the user end.
so for this you can
do like this-> console.log(req.body.name); -- this will print the name (property) in console.