How to split the layer id from url and join with comma

I have set of array of objects containing url, name and address where I want to get the id from url and join them by comma

let arrayOfObjects = [ 
{ url:'http://localhost:3000/redApi?id=001&name=abc&[email protected]'}
{url:'http://localhost:3000/redApi?id=002&name=xyz&[email protected]'}
{url:'http://localhost:3000/redApi?id=undefined&name=pqr&[email protected]'}
]

also if there is undefined I want to pass as empty

expected output

001,002,

Here is my code

 let arrayOfObjects = [ 
    {url:'http://localhost:3000/redApi?id=001&name=abc&[email protected]'},
    {url:'http://localhost:3000/redApi?id=002&name=xyz&[email protected]'},
    {url:'http://localhost:3000/redApi?id=undefined&name=pqr&[email protected]'}
    ]

     let urlId = arrayOfObjects.map(x=> x.url)
     let getUrl = new URLSearchParams("?" + urlId?.url?.split("?")[1])
     let dataId = getUrl.get('id')
     
     console.log(dataId)