title: Passing DB contents from XHTTP request
body: <p>I have an xhttp GET request to fetch the items in my db using its api gateway url.  The request works fine as I can see my db's contents which are in string (key:value pairs) from the browser's dev console.  Where I'm drawing a blank in is how to pass the db's contents to another function that parses it into javascript objects.</p>
  <p>Fetch request code</p>
  <pre><code>function fetch(){
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (this.readyState == 4 &amp;&amp; this.status == 200) {
        console.log(this.responseText);
      }
    };
    xhttp.open(&quot;GET&quot;, &quot;&lt;mygatewayapi_url&gt;&quot;, true);
    xhttp.send();
  }
  </code></pre>
  <p>Code for parsing db contents into javascript object</p>
  <pre><code>function displayObj(dataStr){
      var obj = JSON.parse(dataStr);
      var html = &quot;&quot;;
      var item =;
      //var keys = Object.keys(obj);
      //var last = keys[item.length - 1];
  
      for (item in obj){
          html += '&lt;li&gt;' + item + ' ' + obj[item] + &lt;/li&gt;';
          /*if (last === true)
              html += '&lt;li&gt;' + item + ' ' + obj[item] + &lt;/li&gt;' + &quot;&lt;br&gt;&quot;;*/
      }
      return '&lt;li&gt;'+html+'&lt;/li&gt;';
  </code></pre>