'React - Read properties of undefined (reading 'type')

I am having a problem because I have a read properties of undefined (reading 'type') error that I cannot resolve. I receive the data from my API but the value of 'type' and undefined and I don't understand why? Someone would have any idea ?

export function picture(object) {
  const result = {
    type: 'photo',
    title: object.title,
    photoURL: object.url,
    owner: object.author_name,
    uploadDate: object.upload_date,
    html: object.html,
  };
  return result;
}
export function video(object) {
  const result = {
    type: 'video',
    title: object.title,
    uploadDate: object.upload_date,
    photoURL: object.thumbnail_url,
    owner: object.author_name,
    html: object.html,
    duration: object.duration,
  };
  return result;
}

export function filterData(object) {
  console.log(object);
  if (object.type === 'video') {
    return video(object);
  } else if (object.type === 'photo') {
    return picture(object);
  }
}

console.log(object)

API response



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source