Javascript Object destructure given undefined

I have an object which looks like –

const test = {
  
"data": {

  "status": {
   "coed": "200",
    "desc": "aaa"
},

"data": {
  "id": "aaa",
  "date": "todays date"
}
}

}

here , I have one function

const getData = ({data: { status: { code } }}) => {
return code;
}

calling this function:

getData(test)

So test is a response data , so takes time to get that but till that time the function gets called and gives

can not read property code of undefined

How do I fix this and destructure the data ?

thanks