-2

I have following JSON:

[
   {
      "_id":"1",
      "a":"a",
      "b":"b",
      "c":"c",
      "__v":0
   },
   {
      "_id":"2",
      "d":"d",
      "e":"e",
      "f":"f",
      "__v":0
   }
]

If I do

console.log(myjson[0].a)

And I`m getting following error: TypeError: undefined is not an object (evaluating 'myjson[0].a')

If I do

console.log(myjson)

Then I get

[Object, Object]

How can I get the data from that JSON?

esea123
  • 45
  • 1
  • 6

1 Answers1

0

I've found a solution. All I had to do was just a make a clone of that object.

let note = Object.assign({}, this.props.data.notesData);

And then

console.log(note[0].a);
esea123
  • 45
  • 1
  • 6