title: Read a GET API response to make a second POST API call within one google tag manager server side tag
body: <p>I'm trying to make an API call to <a href="https://legacydocs.hubspot.com/docs/methods/contacts/get_contact_by_utk" rel="nofollow noreferrer">Hubspot Contacts API</a> using the <em>hubspot user token</em>. I want to get the <em>vid</em> in order to then update the contact.</p>
  <p>I am making this API call within <strong>Google Tag Manager Server Side Container</strong>.</p>
  <p>Here is the initial step:</p>
  <pre><code>// retrieve APIs
  const sendHttpGet = require('sendHttpGet');
  const setResponseStatus = require('setResponseStatus');
  const setResponseBody = require('setResponseBody');
  const setResponseHeader = require('setResponseHeader');
  const getAllEventData = require('getAllEventData');
  const JSON = require('JSON');
  
  //set variables
  const hostname ='api.hubapi.com';
  const hubid = data.userToken;
  const path =['/contacts/v1/contact/',data.identificationType,'/'].join('');
  const url = ['https://', hostname,path,hubid,'/profile?hapikey=',data.apiKey].join('');
  
  
  //make api call
  
  sendHttpGet (url, (statusCode,headers,body) =&gt; {
    if (statusCode &gt;=200 &amp;&amp; statusCode &lt;300) {
        data.gtmOnSuccess();
        } else {
      data.gtmOnFailure();
  }
    setResponseStatus(statusCode);
    setResponseBody(body);
    setResponseHeader(headers);
  });
  
  </code></pre>
  <p>I want to be able to receive the API call response, which will have a property called <em>vid</em> to be able to then automatically trigger either another tag, or even within the same tag, that will update the contact using the <em>vid</em> from the first API call.</p>
  <p>How do I do this?</p>
  <p>Is there a way to be able to read the response within this script, map to a variable, and then map the next API call?</p>
  <p>I'd prefer not to use 2 separate tags/scripts for this because it creates more potential breakpoints, and this simplifies the user process.</p>