I have a frustrating issue and I cannot find why it is happening
I have a function as follows:
  public async PageResult(searchRecord:Search,authorization:string,pageNumber:number,databaseName:string){
    some codes .....
    return new Promise((resolve, reject) => {
      this._resultsDatastore.bulkInsert(
        databaseName,
        objects
      ).then(succ => {
        // I can see succ is printed successfully in console
        console.log(succ);
        // when I resolve it here I assume I am returning the result
        resolve(succ)
      }, err => {
        console.log(err);
        reject(err)
      })
    })
  }
So as you can see I resolve(succ) and this way I am returning succ to the caller function
Now I have:
 public async loadResults(
    searchId: string,
    authorization: string
  ) {
   some code....
    const results = udsQuery.pages.map(async (pageNumber: number) => await this.PageResult(searchRecord,authorization,pageNumber,databaseName))
    let all: any=[];
    await Promise.all(results).catch(e => {
      console.log("^^^^^^^^^^^^^^^^^^^^^EEEERRRRRROR^^^^^^^^^^^^^^^^^^^^^^");
    }).then(res=>{
      console.log("suuuuuuuuuuuuuuucesssssssssssssss");
      // issue is here: below prints undefined though succ has value 
      console.log(res);
      all.push(res);
      return res;
    });
  }
So now that I call the PageResult in a map and use promis.all to reslove it instead of succ that I returned in PageResult I get undefined Please see this section in above code:
  console.log("suuuuuuuuuuuuuuucesssssssssssssss");
  // issue is here: below prints undefined though succ has value 
  console.log(res);
Am I missing anything?
 
    