Fetch API - using response.json() throws an unexpected end of input error : <p>When using the Fetch API to fetch some JSON from a REST API on my local server and trying to parse the response with <code>response.json()</code>, I am receiving an <code>unexpected end of input</code> error.</p>

<p>The error is easily reproducible on my local server with the following one-liner:</p>

<pre><code>fetch(new Request('http://localhost:9950/RestService/v2/search/find/1', {mode: 'no-cors'})).then(function(response) { response.json(); });

// Output from Chrome console:
// Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
// VM424:1 Uncaught (in promise) SyntaxError: Unexpected end of input
//     at SyntaxError (native)
//     at &lt;anonymous&gt;:1:128
</code></pre>

<p>If I view the Network tab, I can see that my request was fulfilled by the server, and if I preview the response I can see that there is valid JSON available there (I double-checked this by copying and pasting the JSON from the Network Response tab in to jsonlint.com). Here is a sample of the response I am getting from the server:</p>

<pre><code>{
    "SearchMatches": [{
        "Extracts": ["&lt;b&gt;1&lt;\/b&gt;.txt...", "&lt;b&gt;1&lt;\/b&gt;"],
        "Title": "1.txt",
        "Url": "C:\\TestShare4\\500Docs\\1.txt"
    }]
}
</code></pre>

<p>If I try to use <code>response.text()</code> instead of <code>response.json()</code> I get an empty string.</p>

<p>Any thoughts on where I could be going wrong with this?</p>

<p>Note that I have a requirement to not depend on any other frameworks or libraries other than what is natively supported by the browser.</p>
