title: NodeJS SyntaxError: Unexpected token in JSON at position 0
body: <p>The <code>body</code> of the response from Authorize.net's sandbox API is:</p>
  <pre><code>{
    &quot;messages&quot;: {
      &quot;resultCode&quot;: &quot;Error&quot;,
      &quot;message&quot;: [
        {
          &quot;code&quot;: &quot;E00012&quot;,
          &quot;text&quot;: &quot;You have submitted a duplicate of Subscription 5777085. A duplicate subscription will not be created.&quot;
        }
      ]
    }
  }
  </code></pre>
  <p>but when I go to parse it:</p>
  <pre><code>try {
     bodyObj = JSON.parse(body);
  } catch (ex) {
     console.error(ex);
  }
  </code></pre>
  <p>I get this error:</p>
  <blockquote>
  <p>SyntaxError: Unexpected token  in JSON at position 0</p>
  </blockquote>
  <p>And this: <code>console.log(response.headers['content-type']);</code></p>
  <p>returns this: <code>application/json; charset=utf-8</code></p>
  <p>What am I doing wrong? I want to parse the JSON into a JS object.</p>