0

I have a newbie question I log the following object

1) data
2) data.files
3) data.length (-> 0)
4) data.files[0] (-> undefined)

enter image description here

Here is a the console log for data object

{}
files: Array [ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAzMAA......]

​Here is the console.log of data.files

[]
0: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAzMAAADKCAYAAACR3h76AAAYfWlDQ1BJQ0MgUHJvZmlsZQAAWIWVWQdUFEu......."
​length: 1

​ Here is the gog of data.files.length

0

Here is the log of data.files[0]

undefined

I don't understand why data.files[0] is undefined

flamant
  • 733
  • 4
  • 15
  • 41
  • Please post an example of the object in question instead of a picture of it. – mplungjan Nov 17 '20 at 08:28
  • We can't really help without a fair bit more information, but it's likely you're running into [this problem](https://stackoverflow.com/questions/38660832/console-log-of-element-children-shows-0-length-but-has-three-entries-when-expand) and your code trying to use `data.files[0]` is using it before `data.files` has entries added to it. But again, we can't help without much more information. – T.J. Crowder Nov 17 '20 at 08:29
  • data.file[0] ? , what you need is datas.file[0] – York Chen Nov 17 '20 at 08:29
  • 1
    @YorkChen Obviously a typo – mplungjan Nov 17 '20 at 08:35
  • then it should not be undefined, please check again, if it still happen, please show the entire code. – York Chen Nov 17 '20 at 08:39
  • 1
    @YorkChen or the dupe explains it – mplungjan Nov 17 '20 at 08:43

0 Answers0