ladjs / supertest

🕷 Super-agent driven library for testing node.js HTTP servers using a fluent API. Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
MIT License
13.82k stars 759 forks source link

Keep getting error: "invalid json response body at reason: Unexpected end of JSON input" #701

Open eden-lane opened 3 years ago

eden-lane commented 3 years ago
 FetchError: invalid json response body at  reason: Unexpected end of JSON input

      at node_modules/node-fetch/lib/index.js:272:32

Here is my code:

const response = await request(app)
    .get('/api/demos')
    .expect(200);
Dipesh-Das97 commented 3 years ago

I have faced the same issue with Wretch API. Instead I try to look at the raw response as a solution. If there is a solution with response.json() it would be great.