写小程序时 Cannot read property '0' of undefined 时不时跳出来是怎么回事

wx.request({
url: 'https://music.163.com/api/song/detail/?id=%27+ searchIds[i] +'&ids=['+ searchIds[i] +']',
success:function(res){

        var albumPic = res.data.songs[0].album.picUrl  //此行报错Cannot read property '0' of undefined
        var name = res.data.songs[0].album.name;
        albumPicUrls.push(albumPic);
        that.setData({
          albumPicUrls:albumPicUrls
        })
        if(++i<length){  
          that.getMusicImage(searchIds,i,length);
        }

你先打印下res.data.songs是不是数组,有没有值

没有找到下标是0的res.data.songs