Help my problem is when the program runs, the values on Object.keys is on text, and i want it on variable form so it will call it on the EJS.
the output of the console.log(arr) will be (see code below):
[
'req.body.name',
'req.body.age',
'req.body.sex',
'2017-05-02 08:43:13',
'031418003000',
'1222',
'1234',
'01'
]
The first arr.push (the one with Object.keys foreach loop) is the first three elements is called as text, and i want it on variable or look like the second arr.push.
The second arr.push(the one with dateString variable to the last push) is correct because it called from the EJS.
var arr = [];
var m = new Date();
var input = JSON.parse(JSON.stringify(req.body));
var dateString =
m.getFullYear() + "-" +
("0" + (m.getMonth()+1)).slice(-2) + "-" +
("0" + m.getDate()).slice(-2) + " " +
("0" + m.getHours()).slice(-2) + ":" +
("0" + m.getMinutes()).slice(-2) + ":" +
("0" + m.getSeconds()).slice(-2);
Object.keys(input).forEach(function(key) {
arr.push('req.body.' + key);
});
arr.push(dateString, req.body.eacode, req.body.hcn, req.body.shsn, req.body.MEMBER_CODE );
console.log(arr);
via John Carlo Velasquez
No comments:
Post a Comment