Obviously, it's an ordinary case, when you get an array of objects and you need to create for the reply the array of other Objects, but you need to initialize it on load. For React developers it can be often used with useEffect or componentDidMount.

For example, you got the array:

const matchesData = await this._apiRep.getMatches();

And you need to create an array of the same size with some values from it. 'Map' will help you.


let defaultForecasts:IMatchForecast[] = matchesData.map(x => {
    return (
        {
            betId: x.id??0,
            home: 0, away: 0, userId: 1
        }
    )
})

As a result, you initialize the array and fill it with required properties.