Looking to accomplish the following:
let listOne: any = ['item1', 'item2', 'item3'];
let details: any;
// Previously, I had a loop running and 'row' was the response outputting items
// in the listOne array
const query_for_details = `SELECT column1 FROM tableName WHERE itemId = '${row}'`;
details = await client.query(query_for_details).then((res: any) => res.rows
console.log(details)
// Output for each item in the listOne array {name1: value1, name2: value2, name3:value3}
Now, after obtaining the query output, I aim to store it in a new variable like shown below:
let listOneDetails: any = [{'item1': {'name1': 'value1', 'name2': 'value2', 'name3':'value3'}},
{'item2': {'name1': 'value1', 'name2': 'value2', 'name3':'value3'}},
{'item3': {'name1': 'value1', 'name2': 'value2', 'name3':'value3'}}]
I've looked into using a reducer, but it doesn't seem like the right fit for my scenario. Any help would be greatly appreciated!