This code works when I save my file but when I refresh the browser the nested API request doesn’t work anymore. I would love a push in the right direction.
useEffect(() => { const headers = {‘Authorization’ : `Discogs key=${config.consumerKey}, secret=${config.consumerSecret}`}; axios({ method: ‘get’, url: ‘https://api.discogs.com/users/misaruiz/collection/folders/0/releases’, headers }) .then(response => { if (isLoading) { response.data.releases.map(record => record.basic_information.artists.map( artist => ( axios({ method: ‘get’, url: artist.resource_url, headers }) .then(response => artist.image = response.data.images[0].uri) .catch(error => console.log(‘Error fetching and parsing data for artist’, error)) ) )); setData(response.data); } }) .catch(error => console.log(‘Error fetching and parsing data’, error)) .finally(() => setIsLoading(false)); });
submitted by /u/Ninjatello
[link] [comments]