The api I am working with requires time in the HH:MM:SS format however my output is simply showing a numeric value for the time(for example: 8:00am is output as 8). How can I convert this to HH:MM:SS format?
let targetStr = getTree().data.boards[0].groups[0].items[0].name;
let fields = ['DATE', 'TIME', 'DURATION', 'TYPE'];
console.log(extractData(targetStr, fields));
function extractData(str, fields) {
return str.split(/\s*\|\s*/).reduce((res, entry) => {
let dat = entry.split(/\s*:\s*/);
return fields.indexOf(dat[0]) > -1 ? Object.assign(res, { [dat[0]]: dat[1] }) : res;
}, {});
}
function getTree() {
return {
"data": {
"boards": [{
"owner": {
"id": 555555555
},
"groups": [{
"id": "new_group",
"title": "Forecasts",
"items": [{
"id": "355670938",
"name": "PIPE: Production & Client Management | STAGE: New Support Intake | NAME: TESTY | DATE: 10/27/2019 | TIME: 8:00 am | TIME ZONE: Central Time | DURATION: 60 minutes | TYPE: All Virtual | AUDIENCE VIEW:"
}]
}]
}]
},
"account_id": 55555555
};
}