Closed woacademy closed 3 years ago
If you set a timeout, the request times out. Can you try the main
branch?
npm install "sindresorhus/got#62305d77d3428b5c714d21b4bbee68cc75b5f787"
Can you try the
main
branch?
$ npm install "sindresorhus/got#62305d77d3428b5c714d21b4bbee68cc75b5f787"
[...]
> got@11.8.0 build
> del-cli dist && tsc
test/stream.ts:490:35 - error TS2769: No overload matches this call.
The last overload gave the following error.
Type 'Readable' is not assignable to type 'string | Readable | Buffer | undefined'.
Type 'Readable' is missing the following properties from type 'Readable': readableEncoding, readableEnded, readableObjectMode, pipe, and 8 more.
490 const response = await got.post({body});
~~~~
source/core/options.ts:1058:6
1058 get body(): string | Buffer | Readable | undefined {
~~~~
The expected type comes from property 'body' which is declared here on type 'OptionsInit'
source/types.ts:171:2
171 (options: OptionsInit): CancelableRequest | Request;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The last overload is declared here.
Found 1 error.
error Command failed with exit code 1.
In that case try cloning the repo and builiding it from there.
npm install && npm run build
@szmarczak this gives me the same error, even when building the commit you referenced. The same error can be seen in the builds on GitHub.
Managed to install got from HEAD with the latest commit and it still hangs when running this sample. A timeout can be set but that doesn't resolve the issue of request working on got not.
It's very likely that the issue is with FormData
. Replacing FormData
with string gives me 401 as expected. Continuing investigation.
Looks like a FormData
bug: https://runkit.com/szmarczak/60bded210d856c0013ab2b6b
Passing it to PassThrough
first does the trick.
Looks like a
FormData
bug: https://runkit.com/szmarczak/60bded210d856c0013ab2b6bPassing it to
PassThrough
first does the trick.
Thank you for looking into this, appreciate it! This does seem to get one step closer but the 401
is unexpected, request comes back with a 302
which I'd expect as that's what I see when executing this with a browser. To be clear the response code should be 302
regardless of failure or success. Any ideas?
...
followRedirect: false,
...
Thank you. Everything is working as expected now, unfortunately when passing the correct credentials request is able to login, and got isn't (with console.log(response.headers.location);
):
$ node index.js foo bar
dashboard/admin
Request true
?wicket:interface=:0::::
Got false
I realise you won't be able to help me diagnose that part but could you describe how to pass it as a string like you mentioned earlier?
It's very likely that the issue is with FormData. Replacing FormData with string gives me 401 as expected.
could you describe how to pass it as a string like you mentioned earlier?
Simply pass a string
to body
. body: 'data'
I realise you won't be able to help me diagnose that part
You can use Wireshark or any other tool to debug this.
Note that in the request
example you're using application/x-www-form-urlencoded
but in the Got example you're using multipart/form-data
. Got accepts the first as well, using the form
option.
Describe the bug
I'd like to convert a piece of code that logs into a website and retrieves some data from
request-promise
togot
. The login information is not important (node index.js foo bar
) as the request-promise sample will fail but the got request will hang for a long time and seemingly never resolve. The expected response is a 302, with the location header being used to verify login success.v15.4.0
macOS Big Sur 11.4
Actual behavior
Expected behavior
Code to reproduce
Checklist