RT,list contains 100 songs. Now traverse it, get the mid, of each song as the getSongvkey (jsonp) parameter to get the vkey value asynchronously, and then add vkey as an attribute to the song through the creatSong method. This vkey value needs to be used to obtain the song"s playback link.
the problem now is that the data is obtained asynchronously. When I iterate through the forEach according to the following code, I can only get how the vkey, of the last item gets its mid every time it traverses an item, and then asynchronously gets its vkey return, and then processes the next item?.
_normalizeSongs(list) {
let ret = []
list.forEach((item) => {
let { musicData } = item
if (musicData.songid && musicData.songmid && musicData.albummid) {
getSongvkey(musicData.songmid).then(res => {
if (res.code === ERR_OK) {
let vkey = res.data.items[0].vkey
ret.push(creatSong(musicData, vkey))
}
})
}
}
return ret
}