Unhandled Rejection (TypeError): Cannot read property 'items' of undefined
24 | })
25 | .then(response => response.json())
26 | .then(json => {
27 | const artist = json.artists.items[0]; 🚀
28 | this.setState({ artist });
29 |
30 | FETCH_URL = ${ALBUM_URL}${artist.id}/top-tracks?country=US&;
In line 27, I kept encountering the same error, what is 0 referring to?
you need to send your request like this fetch(FETCH_URL,{ method: 'GET', headers: { 'Authorization': 'Bearer ' + accessToken }, mode: 'cors', cache: 'default' }).then.... Because you are not getting your token send in the request, and you are not getting any object back, thats why you get an undefined object. Also if your token expired you need to generate a new one.
access Token is not defined error and header is not defined error