0

When i read a json object it return me

Cannot read properties of undefined (reading '0')

Someone can help me ? i tested few things but no one is working

this is my code :

      fetch('https://api.hyper.co/v6/licenses?page=1&limit=100', options)
        .then(response => json = response.json())
        .then(response => console.log(response))
        .catch(err => console.error(err));

      console.log(json['data'][0]['email'])

I want to get email of a json object response of an api

  • In addition to the asynchronous code references in the linked duplicate(s), `json = response.json()` also doesn't do what you think it does. `response.json()` returns *a Promise*, not the actual resulting JSON. That's why you append another `.then()` callback. That second `.then()` callback is where you get the actual resulting JSON and you can log your "email" value there. – David Dec 01 '22 at 19:54

0 Answers0