I try to nest Ajax requests and return a whole array of results.
I have a first API call and I need to do do other requests according to the first result.
The order is the following:
- First API call
- Loop on results and for each result : do API2 call
- return an array of each element : [{Result1-item, Result2-item})
This is
function getVideos () {
    return $.ajax({
        url: 'URL1'
    })
        .then(function (list) {
            let videos = [];
            list.videos.function(video) {
                return $.ajax({
                    url: video.url_id
                })
                    .done(function (videoInfo) {
                        videos.push({video: stream, videoInfo: videoInfo})
                    });
            })
        })
        .done(function (allResult) {
            return allResult;
        });
}
The calls are doing great but I don't get how to gather the video + video infos in the same array
What is missing ?
 
    