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)
})