Open mt-u opened 2 years ago
I am able to reproduce. I bisected the Deno version and found that Deno 1.12.0 is where it breaks.
The error message points to this line in Deno's code:
So I guess the request URL is being turned into a Blob URL somehow? Not sure why that would be happening. We're certainly not doing that intentionally and given that we're not having this problem in other environments or on older versions of Deno, I'm inclined to say this should be reported to the Deno team as a regression. But it's possible we're doing something funky - needs more investigation.
Repro code:
import ky from 'https://cdn.skypack.dev/ky?dts'
const url = 'https://httpbin.org/anything';
const body = new FormData();
body.append('username', 'janedoe');
// const response = await fetch(url, { method : 'POST', body });
const response = await ky.post(url, { body });
console.log('response:', response);
console.log('form:', (await response.json()).form);
I found that wrapping the form data in a URLSearchParams
works.
const url = 'https://example.com';
const formData = new FormData();
formData.append('username', 'test');
r = await ky.post(url, { body: new URLSearchParams(formData) });
It's caused by https://github.com/denoland/deno/issues/16570 , fetch(request.clone())
does not work in Deno when there is a stream body.
Is this still happening with latest Ky and Deno?
Hi. I get an error when I send form data using
ky.post
method onDeno 1.13.2
. Error message is below:It is no problem on
Deno 1.11.5
. But onDeno 1.13.2
, it fails. Even though rawfetch
(globalThis.fetch
) succeeds.ky.post
withjson
also succeeds.There may be some discrepancies between what your library expects and the latest Deno implementation.
I tried using a Deno Docker container. The command used is:
This is my sample code:
results: