I am relatively new to node and trying to create an web app that allows users to get retrieve information from the youtube api by providing a list of youtube channel IDs(already in server) by going to my /retrieve route.

Currently I am looping through an array of objects with channel IDs, and for each ID I use a setTimeOut function to send 1request/500ms (due limitations of the youtube API) and using the request.get request module. I am trying to continue code and res.send AFTER all the requests to youtube is completed. Furtherfore, for each data obj I received from each youtube request, I am parsing and pushing them to the youtubeinfo array.

I have a nodeJS version of v12.16.3.

Here's my code below, sorry for the messiness:

```
router.get('/retrieve', async function(req, res, next) {
  console.log("start")
  const length = datajs.length
  console.log(length);
  var promiseArray = [];
    for(i = 0; i < length; i++){
    promiseArray.push(new Promise((resolve, reject) => {
    (function(i){
        setTimeout(function(){
          const channelID = datajs[i]['Channel ID']

          let options = {
              method: 'GET',
              url: url, //url is previously defined

          };
          request.get(url, (err, response, data)=>{
            if (!err) {

              parsedData = JSON.parse(data)
              if (parsedData.items){
                // check with retrievede data obj is valid format with items
                const parsedYoutubeobj = {
                "custom_collection": {
                  "title": parsedData.items[0].brandingSettings.channel.title,
                  "body_html": parsedData.items[0].brandingSettings.channel.description,
                  "image": {
                    "src": parsedData.items[0].brandingSettings.image.bannerImageUrl,
                    "alt": "Rails Logo"
                  }
                }
              }
              youtubeinfo.push(parsedYoutubeobj)
              console.log("----------------------")

              console.log(parsedYoutubeobj);
              youtubeinfo.push(parsedYoutubeobj);
              resolve(parsedYoutubeobj)
              } else {
                console.log("something is wrong...check if youtube channel still exist")
                reject()
              }

            } else{
              console.log("statusCode: "+ response.statusCode)
              console.log("err: "+ err);
              reject(err)

            }
          })
      }, 500 * i);
    }(i));
  }))
  }

```

How can I correctly apply promises/async/await to have my code continue after all the async requests are made? I currently creating an array of promises, but it does not seem to work?