I just don't know why it isn't working. here are my states.
const [albums, setAlbums] = useState([])
const [artist, setArtist] = useState([])
const [artistImages, setArtistImages] = useState([])
and here I'm setting the states.
axios.get(`/music/api/artist/1/`)
.then(res => {
setAlbums(res.data.albums);
setArtist(res.data);
setArtistImages(res.data.about_images);
console.log(res.data.albums)
}).catch(err => {
console.log(err)
})
this is the response I'm getting from server
BgImage: "http://127.0.0.1:8000/media/images/001_3uKSvDp.jpg"
about_images: Array(1)
0: {id: 1, image1:
"http://127.0.0.1:8000/media/images/1034349_xl06j1h.jpg",
image2: null, image3: null, image4: null, …}
length: 1
__proto__: Array(0)
albums: Array(3)
0: {id: 1, album_name: "Fearless (Taylor's Version)", artwork:
"http://127.0.0.1:8000/media/images/001.jpg", artist: "Taylor Swift"}
1: {id: 7, album_name: "Reputation", artwork:
"http://127.0.0.1:8000/media/images/001_1.jpg", artist: "Taylor Swift"}
2: {id: 8, album_name: "1989", artwork:
"http://127.0.0.1:8000/media/images/002.jpg", artist: "Taylor Swift"}
length: 3
__proto__: Array(0)
artist_name: "Taylor Swift"
born: "1989-12-13"
id: 1
image: "http://127.0.0.1:8000/media/images/011.jpg"
problem I'm having is only setAlbums
does not get set. all other states set like setArtist
setArtistImages
just Album does not set. and even if I console.log(res.data.albums)
it returns the album. but setAlbum does not work. I just don't know why....