0

I have an array as part of an object whose elements I need to access. However, everything a tried so far failed. Could you give me any hints? Thanks! Here is the object shown with console.dir (data) which is the object:

[Log] Object (main.chunk.js, line 743)

networkData: Array (1)
  0 Array (2)
    0 Object

      __typename: "networkDat"

      source: 2

      target: 1

   Object Prototyp
 1 Object

      __typename: "networkDat"

      source: 1274

      target: 3

   Object Prototyp

  Array Prototyp

 Array Prototyp

Object Prototyp

In particular, I need to access the "source" and "target" values.

Nick
  • 138,499
  • 22
  • 57
  • 95
Tobias
  • 1
  • 1
  • What you've posted is just a console dump. Please post your `networkData` object in JSON. – Dai Sep 14 '20 at 08:13
  • It depends on what you want to access, the object seems to have a `networkData` that has as value an array of arrays. To access the array of arrays you can use `data.networkData`, to access the first element in the inner array (this array has only one element) you could use `data.networkData[0]`. – Titus Sep 14 '20 at 08:16
  • Here is the JSON format: {"networkData":[[{"source":2,"target":1,"__typename":"networkDat"},{"source":1274,"target":3,"__typename":"networkDat"}]]} – Tobias Sep 14 '20 at 09:50
  • I tried data.networkData[0] but it gives me "TypeError: undefined is not an object (evaluating 'data.networkData')" – Tobias Sep 14 '20 at 09:52

0 Answers0