Answers for "code in nested forEach loop- react native"

0

code in nested forEach loop- react native

const nestedPromise = async (items = []) => {
  return await Promise.all(
    items.map(async item => {
      if (Array.isArray(item) && item.length) {
        return await nestedPromise(item)
      }
      // return await call to your function
      return 'response-' + item
    })
  )
}

const items = [ [4, 1, 2], [2, 5] ]
nestedPromise(items).then(results => {
  console.log(results)
})
Posted by: Guest on June-12-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language