I am attempting to extract values from a JSON response by using key values stored in a separate array. However, when I try to log the results, I am only getting 'undefined'. Here is my code:
let fdName =["SerialNo","denDate","denShift","denTime","denWs_1","denWs_2","denVol_1","denVol_2","denPwdrMix"];
let dtValue = [{
id: 1,
SerialNo: 1,
denDate: "2019-09-09",
denShift: "Day",
denTime: "10:32:00",
denWs_1: 10.23,
denWs_2: 11.2,
denVol_1: 12.5,
denVol_2: 10.12,
denPwdrMix: 0.75,
created_at: null,
updated_at: null
}];
var savedData = fdName.map(function(e) {
var filteredRes = dtValue.find(a => a[key] == e);
return filteredRes ;});
console.log(savedData);
Expected output:
[1, 2019-09-09, Day, 10:32:00, 10.23, 11.2, 12.5, 10.12, 0.75];
I would like to display these obtained results in a table using v-for
as shown below:
<tbody>
<tr>
<td
v-for="(dtValue, sdtValue ) in savedData "
:key="sdtValue"
>
{{dtValue}}
</td>
</tr>
</tbody>