score:2

Accepted answer

making the below changes produces the desired result:

  1. use find instead of filter in getproduto().
  2. correct typo in getprodutoadicionaischecked(). replace itensa with itens.
  3. modify getprodutos() as shown below. this code iterates over the products in the cart and for each product, fetches the product details, produtoopcoeschecked and produtoadicionaischecked returning all these data within a single object.

hence the method returns an array of objects, where object has the consolidated data for each product in the cart.

const getprodutos = () =>{
   const produtoresult = produtoscart.map((item) => 
     {
        return {
            // get the product data
            ...getproduto(item.id), 

            // get the options data
            produtoopcoes: getprodutoopcoeschecked({groupid:item.idopcoesgroup, 
            idx: item.idopcoes}),  

            // get the additiones data
           produtoadicionais: getprodutoadicionaischecked({groupid: item.idadicionaisgroup, idx: item.idadicionais})
        }
     }
    ); 
    return produtoresult;

}

Related Query

More Query from same tag