title: Returning data from promise to a variable using map
body: <p>I want to return the data to a variable.
  I have resolved the promise and making it print to console. I want that the data should be access outside and can be used by a variable.
  I want whatever values are there in console.log(x) , should come outside the loop in a variable ( say variable name z)</p>
  <pre><code> var libobj =await service.getdata(); //----------&gt; returning from service file and libobj is returning  promise (fullfilled)
  
  // var z; -----Data needed here or below the map loop
  
  libobj.map( (res: any) =&gt; 
  (res.then((x : any )=&gt;console.log(x)) )); //--------&gt; console .log(x) printing all  the data needed
  </code></pre>