title: How to return new variable after some promise process?
body: <pre><code>getCategory().then((res) =&gt; {
    let itemList = res;
    return new Promise((resolve, reject) =&gt; {
      for(let i=0; i &lt; res.length; i++ ) {
        getItems(res[i].url).then((itempage) =&gt; {
          const $ = itempage;
          const pagination = $('.pagination .page').toArray().length;
          itemList[i].total_page = pagination;
        });
      }
      resolve(itemList);
    });
  }).then((res) =&gt; {
    console.log(res);
  });
  </code></pre>
  
  <p>Above is my code. First of all, I assign <code>res</code> to a new variable called <code>itemList</code> which is an object array.
  Then I do some functions with promise and try to add new data to <code>itemList</code>.</p>
  
  <p>However, when the <code>console.log(res)</code> still prints out original <code>itemList</code>.</p>
  
  <p>I know this may caused by promise function but how to fix it?</p>