I'm trying to add data to an array of objects that will look like this:
[
{text: 'title content | subtitle content'},
{text: 'more title content | and more subtitle content'},
{text: 'even more title content | and some more subtitle content'}
]
My data is coming from a fetch request, returning an array of objects. I'm trying to set the data that I receive from the fetch request to an array called 'array', like this:
let data = this.state.data; //data from fetch request
array.push(data.map(item, i) => {
{text: `{item.content_title | {item.content_subtitle}`}
});
I've placed the above codeblock in the componentDidMount() lifecycle method. I'm getting a parsing error when running this code. How can I push the fetched data to the array?