sindresorhus / got

🌐 Human-friendly and powerful HTTP request library for Node.js
MIT License
14.27k stars 935 forks source link

got response no data #1434

Closed neigence closed 4 years ago

neigence commented 4 years ago

Describe the bug

Actual behavior

...

Expected behavior

...

Code to reproduce

...

Checklist

I am a beginner of this package, after I install got@11.6.0 and run an example, it output nothing.

After I downgrade to got@11.3.0, everything goes fine

const got = require('got');

(async () => { const body = await got.post('http://localhost:8888/test/test', { json: { hello: 'world' } }).json();

console.log(body);
//=> {…}

})();

Giotino commented 4 years ago

Your issue seems related to the web server, we need more information and some code to reproduce the issue (your code depends on a local webserver).

This example works fine

const got = require('got');

(async () => {
  const body = await got
    .post('http://postman-echo.com/post', {
      json: {
        hello: 'world',
      },
    })
    .json();

  console.log(body);
})();
download13 commented 4 years ago

I think I'm getting the same problem?

Windows 10 v1909 node 14.1.0 got 11.6.0

Open REPL w/ node --experimental-repl-await

> { default: got } = await import('got')
> await got('https://ifconfig.co/', { resolveBodyOnly: true })
''
> await got('http://example.org', { resolveBodyOnly: true })
''

It just returns an empty string for the body every time. No idea what to make of it. Can anyone replicate?

szmarczak commented 4 years ago

Upgrade your Node.js