Unable to set property ‘Property name’ of undefined or null reference

Browser IE11
AngularJS
Api returning data and is being loaded to custom objects like

apiData.map(function(item){
 return {
    id: item.Id,
    name: item.Name,
    types:{}
});

This ‘types’ property is being populated as following by init method:

for (int i=0, i<data.length; i++){
data[i].types = getTypes(); -- this line gives undefined error
}

Can you please tell what is wrong here?
getTypes() function is returning correct data.

Thanks in advance for providing suggestions.
Sonali Das

Source: AngularJS Questions