Closed shian15810 closed 4 years ago
Just FYI, wretch().polyfills({ fetch })
is working perfectly with deno-provided fetch
.
Hi @shian15810,
Thank you for this amazing package!
Thanks a bunch!! 😄
Any idea what is causing these errors?
Yes, you need to enable the dom
type definitions in the typescript configuration file.
Basically when running deno, specify the location of a tsconfig.json
file having the following contents:
{
"compilerOptions": {
"lib": [ "es2015", "dom" ],
},
}
Then, run deno with the following command line arguments:
deno -c tsconfig.deno.json --allow-net program.ts
I tried with the following program and it seemed to work like a charm:
import wretch from 'https://cdn.pika.dev/wretch'
const html = await wretch('https://google.com').get().text()
console.log(html)
Hope this will help! 👍
Yeah, thanks for your help!
lib="dom"
conflicts with lib="deno.shared_globals"
, which is very much required to use Deno
internals, so it is nearly impossible to utilize lib="dom"
in deno ATM.
I guess I will have to wait https://github.com/denoland/deno/issues/3974 for RequestInit
and https://github.com/denoland/deno/issues/3345 for AbortController
to land on lib="deno.shared_globals"
.
Thanks again for this amazing library!!!
lib="dom" conflicts with lib="deno.shared_globals", which is very much required to use Deno internals, so it is nearly impossible to utilize lib="dom" in deno ATM.
Ah thanks for sharing, I did not know that. I'll look into deno a bit more in the future 👍.
Thanks again for this amazing library!!!
🙇
As of deno 0.41.0, AbortController
and RequestInit
are both exposed in the global scope, thus allowing wretch to be imported in deno.
import wretch from "https://cdn.pika.dev/wretch";
wretch().polyfills({ fetch, FormData, URLSearchParams });
await wretch('https://httpstat.us/200').get().text();
The above code can run with no problem in deno 0.41.0.
If you are interested in deno, maybe you can add information about deno support in README.
If you are interested in deno, maybe you can add information about deno support in README.
@shian15810 I just added a paragraph about Deno, thanks for the suggestion!
Also it turns out that the .polyfills(...)
part is not necessary since wretch
uses the global values by default which makes it even easier to use with Deno 😄.
Yeah, didn't noticed that! The global of deno is window
, which is purposely made to be browser compatible.
Hi there, I have been using wretch for a very long time, and hoping to use it in deno too.
Since wretch is packaged as a esmodule, it is possible to import wretch directly in deno.
import wretch from "https://cdn.pika.dev/wretch";
However, I'm getting some typescript errors in some d.ts files in dist:
I can see they are not referenced anywhere in their corresponding files.
Any idea what is causing these errors?
Thank you for this amazing package!