I have a scenario where I am reading a yaml file and based upon the data, make calls to tag aws resources.
await Promise.all(doc?.SQS.map(async (queue)=>{
// code to tag 1 queue
}))
Now the yaml file may not have a any sqs, in which case doc?.SQS
returns undefined as expected. How can I make the map to not run in this scenario ? I tried below but it didn't work as expected.
await Promise.all(doc?.SQS?.map?.(async (queue)=>{
// code to tag 1 queue
}))
.
await Promise.all(doc?.SQS && doc?.SQS?.map(async (queue)=>{
// code to tag 1 queue
}))