I need to convert values ββfrom one Array variable to fields of another variable in Javascript.
My variable
field = ["entries", "body"]
and he needs to become something like
req.body.entries.body
I tried to do something like
field.forEach(function(prop){
req.body[prop] = "...";
}
but this only works on req.body.entries and req.body.body. And I need it to go all the way to req.body.entries.body
I do this to get the data from the form in the document field (named entries [body]), do some cleaning of that data, and then pass it back to node.js, as if it were a request that was originally made.
UPDATE
All I have to do is basically
exports.sanitize = function(field){
return function(req, res, next){
val = getField(req, field);
val = some_process(val);
req.body.entry.body = val;
next();
}
};
, , , - entry.body, , .
, , .
!