I am trying to populate a table with an array (products). My data works however it's currently putting all of the information in one row:
const products = [{
username: JSON.stringify(data, ['from']),
content: JSON.stringify(data, ['content']),
date: JSON.stringify(data, ['updatedAt'])
}]
However, I'm trying to create a for loop to make a new object for every data item. I thought I had the right concept but this isn't working at all:
const products = [
for (let i = 0; i < data.length; i++) {
username: JSON.stringify(data[i], ['from']),
content: JSON.stringify(data[i], ['content']),
date: JSON.stringify(data[i], ['updatedAt'])
}]
Can anyone point me in the right direction?
username: data.from? Why are you stringifying all the things?Array.prototype.map