title: Changing the keys in array of objects || javascript
body: <p>I have an array of objects from some api call. Each of these objects have a key named id. I want to change this id to post_id for each object in the array
  The first key in each object is id, so I have accessed index 0 in the code below.</p>
  <p>Thanks in advance.</p>
  <pre class="lang-js prettyprint-override"><code>function changePostId(receivedData) {
    receivedData.forEach(obj =&gt; {
      var keys = Object.keys(obj);
      var key = keys[0].replace(/^id/, &quot;post_id&quot;);
      tmp[key] = obj[keys[0]];  
    });
  }
  </code></pre>