title: node-fetch help - getting FetchError: invalid json response > body at <url> reason: > Unexpected end of JSON input
body: <p>I am new to node.js and APIs so I am hoping someone can help! I am trying to use node-fetch to get JSON data from the fantasy premier league API. I have successfully done this in the client, but from my node.js server file I keep getting the error:</p>
  <blockquote>
  <p>UnhandledPromiseRejectionWarning: FetchError: invalid json response
  body at <a href="https://fantasy.premierleague.com/api/entry/3/" rel="nofollow noreferrer">https://fantasy.premierleague.com/api/entry/3/</a> reason:
  Unexpected end  of JSON input</p>
  </blockquote>
  <p>The response itself has a status of 200, but the size is 0 so it is not returning any data. I know it should work, as the JSON is plainly visible when you visit the url and I have got fetch to work in the client-side code.</p>
  <p>Here is the code I am using:</p>
  <pre><code>const fetch = require('node-fetch');
  
  async function fetchEntry() {
      const api_url = 'https://fantasy.premierleague.com/api/entry/3/';
      const fetchEntry_response = await fetch(api_url);
      const json = await fetchEntry_response.json();
      console.log(&quot;json: &quot; + JSON.stringify(json));
  };
  
  fetchEntry();
  </code></pre>
  <p>Note: On the client-side code I got a CORS error so needed to use a proxy (<a href="https://thingproxy.freeboard.io/fetch/https://fantasy.premierleague.com/api/entry/3/" rel="nofollow noreferrer">https://thingproxy.freeboard.io/fetch/https://fantasy.premierleague.com/api/entry/3/</a>) to get it to work. I'm not sure if this is relevant?</p>
  <p>Any help would be greatly appreciated!</p>
  <p>Joe</p>