title: Unexpected token u in JSON at position 1
body: <p>I know this is common question, but I keep getting this error when fetching data:</p>
  
  <blockquote>
    <p>SyntaxError: Unexpected token u in JSON at position 1 at JSON.parse ()</p>
  </blockquote>
  
  <p>This happened when I testing my full code, so I made tested with</p>
  
  <pre><code>res.send(JSON.stringify({"data": "test"}));
  </code></pre>
  
  <p>In my client side, I'm using this code:</p>
  
  <pre><code>fetch(url)                                   // fetch works
      .then(checkStatus)                       // checks for errors, if none send response text
      .then(function (responseText) {
          let data = JSON.parse(responseText); // where I'm getting the error
  </code></pre>
  
  <p>When testing the values, everything in my server side prints the correct values. However, when I use console.log to print out the responseText on the client side, I get this:</p>
  
  <blockquote>
    <p>f text() { [native code] }</p>
  </blockquote>
  
  <p>Why is this error being called? From looking around stack overflow, I understand that this error happens when I attempt to parse a string that's undefined. I put an if statement before the parse to check is the string is undefined:</p>
  
  <pre><code>if (responseText === undefined) {
      console.log("responseText is undefined");
  }
  </code></pre>
  
  <p>But it didn't output, so is the string really undefined? As a side note, node is up to date. Thank you for helping.If this is answered in another question, please let me know. I haven't found a solution to this problem. </p>
  
  <p>Edit:</p>
  
  <pre><code>function checkStatus(response) {
      if (response.status &gt;= 200 &amp;&amp; response.status &lt; 300) {
          return response.text;
      } else if (response.status === 404) {
          clear();
          return Promise.reject(new Error("Sorry, we couldn't find that page"));
      } else {
          console.log(response.text());
          return Promise.reject(new Error(response.status + ": " + response.statusText));
      }
  }
  </code></pre>
  
  <p>Edit: response.text is supposed to be response.text(). This gave me my error. </p>