If {{response_1}} always returns the date and time in this format: 2020-08-20T12:45:14.245Z
how can I split date and time into their own columns, removing the T and Z?
I know I need to do something like this:
var respOne = {{response_1}};
var getDate = respOne.substring(0,10);
var getTime = respOne.substring(11,23);
I can then use getDate in the date cell and getTime in the time cell. I am just not sure of the correct syntax to use between the td tags.
var responseDataModified = pm.response.json().data; // the content sent to the Echo endpoint is nested into the property 'data'
responseDataModified.forEach(entry => {
// convert former string into object, may create and use another new property if you like to keep the original value as well
entry.response_1 = {
day: entry.response_1.substring(0, 10),
time: entry.response_1.substring(11, 19)
};
});
var template = `
<table class="tftable" border="1">
<tr>
<th>Response 1 (Day)</th>
<th>Response 1 (Time)</th>
<th>Response 2</th>
<th>Response 3</th>
</tr>
{{#each response}}
<tr>
<td>{{response_1.day}}</td>
<td>{{response_1.time}}</td>
<td>{{response_2}}</td>
<td>{{response_3}}</td>
</tr>
{{/each}}
</table>
`;
pm.visualizer.set(template, {response: responseDataModified});