How to fetch()
a file to specific directory?
#17026
Answered
by
ayame113
Kenya-West
asked this question in
Q&A
-
Currently, |
Beta Was this translation helpful? Give feedback.
Answered by
ayame113
Dec 14, 2022
Replies: 1 comment
-
To write the fetch result to a file, the following should work. const { body } = await fetch("https://google.com");
const file = await Deno.open("./tmp/tmp.txt", { append: true, create: true });
body?.pipeTo(file.writable); The following should also work. const res = await fetch("https://google.com");
const content = await res.text();
await Deno.writeTextFile("./path/to/dir", content); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Kenya-West
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To write the fetch result to a file, the following should work.
The following should also work.