title: Why does this GET request seem to give random characters?
body: <p>This is 1 of my first times using the https node.js module and I tried to make a <code>GET</code> request with this code</p>
  <pre class="lang-js prettyprint-override"><code>const url = new URL(&quot;valid url&quot;) //I did put a valid url
  
  https.get({
      host: url.hostname,
      path: url.pathname,
      headers: {
          &quot;Content-Type&quot;: &quot;application/json&quot;
      }
  }, (res) =&gt; {
      res.setEncoding(&quot;utf8&quot;)
      let str = &quot;&quot;
      res.on(&quot;data&quot;, c =&gt; {
          console.log(c)
      })
  
      res.on(&quot;end&quot;, () =&gt; {
          console.log(str) //this was meant to log the data but I removed the &quot;str += c&quot; from the data callback
      })
  })
  </code></pre>
  <p>But this logs the following:</p>
  <pre class="lang-none prettyprint-override"><code>▼�
  �VJ-*�/��LQ�210ЁrsS��‼�S����3KR§2�§�R♂K3�RS�`J�↕sA�I�)�♣�E@NIj�R-��♥g��PP
  </code></pre>
  <p>But I would think <code>.setEncoding(&quot;utf8&quot;)</code> would work. Is it something to do with the headers? Or maybe the <code>URL</code> object? The result I want is in a <code>&lt;pre&gt;</code> element and is valid JSON.</p>