title: How could I use the Recursion function to push array in javascript
body: <p>I am trying to use the recursion function to push the data in the tempList, however no matter how to fix the code still is an empty array.</p>
  
  <pre><code>let tempList=[]
  var getWineList =  function(database_name,locaDataBase){
      return new Promise(async (sucess,fail)=&gt;{
  
  
          wineList(0,database_name)
          console.log(tempWineList)
          sucess("a")
      })
  }
  
  function wineList(currentPosition,database_name){
  
      let wines= db.collection(database_name)
      .skip(currentPosition)
      wines.get()
          .then((res)=&gt;{
  
  
              // tempList.forEach(function(wine,index){
              //  tempWineList.push(wine)
              // })
  
              if(res.data.length&lt;20){
                  console.log(res.data)
                  return res.data
  
              }
              tempWineList.push(res.data)
              return tempList.push(wineList(currentPosition+20,database_name))
          })
  
  
  }
  </code></pre>