[Vuejs]-How can i push an object to promises in vueJS?

0πŸ‘

βœ…

To manipulate Promise resolved values, you have to use .then, or await, to wait for the Promise to resolve and then act on the resolved value and return your new resolved value.

  self.fetchFeaturedCategories() // assuming this is an array of Promises
   .then(categories => categories.map(category => {
      const parentCategory = {
        gender: category.gender,
        id: category.id,
        imageUrl: category.imageUrl,
        isFeatured: category.isFeatured,
        name: 'All ' + category.name,
        parent: category.parent,
        parentId: category.parentId,
        slug: category.slug,
        type: category.type,
      };
      const categoryMerged = {
         ...category, children: [parentCategory, ...category.children||[]]
      };
      return categoryMerged;
   }));

Leave a comment