Error on custom code in association Endpoint

I’m having trouble with new or saved custom codes after 01/30/2023.

When I try to make this call below, it returns this error:

let idContact;

 const toObjectType = "contact";

 try {
 const apiResponse = await hubspotClient.crm.tickets.associationsApi.getAll(event.object.objectId,toObjectType);
 idContact = apiResponse.body.results[0].id;
 console.log(idContact);
 console.log(JSON.stringify(apiResponse.body, null, 2));
} catch (e) {
 e.message === 'HTTP request failed'
 ? console.error(JSON.stringify(e.response, null, 2))
 : console.error(e)
}

2023-02-03T19:27:37.476Z ERROR TypeError: Cannot read properties of undefined (reading 'results') at Object.exports.main (/var/task/file.js:17:34) at processTicksAndRejections (node:internal/process/task_queues:96:5) 2023-02-03T19:27:38.234Z ERROR RequiredError: Required parameter contactId was null or undefined when calling BasicApi.getById. at BasicApiRequestFactory.<anonymous> (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/contacts/apis/BasicApi.js:83:23) at Generator.next (<anonymous>) at /opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/contacts/apis/BasicApi.js:8:71 at new Promise (<anonymous>) at __awaiter (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/contacts/apis/BasicApi.js:4:12) at BasicApiRequestFactory.getById (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/contacts/apis/BasicApi.js:80:16) at ObservableBasicApi.getById (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/contacts/types/ObservableAPI.js:98:59) at PromiseBasicApi.getById (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/contacts/types/PromiseAPI.js:37:33) at Object.exports.main (/var/task/file.js:29:67) at processTicksAndRejections (node:internal/process/task_queues:96:5) { api: 'BasicApi', method: 'getById', field: 'contactId' }

I did the following test: I copied and pasted this same code into another custom code created and saved before 01/30/2023 and it works normally.