Fetch data
- Like browsers, Deno implements web standard APIs such as
fetch.
- Deno is secure by default, meaning explicit permission must be granted to
access the network.
- See also: Deno’s model.
/**
* Receiving a file
*/
if (fileResponse.body) {
const file = await Deno.open("./logo.svg", { write: true, create: true });
const writableStream = writableStreamFromWriter(file);
await fileResponse.body.pipeTo(writableStream);
}
/**
import { readableStreamFromReader } from "https://deno.land/std@$STD_VERSION/streams/mod.ts";
const file = await Deno.open("./logo.svg", { read: true });
const readableStream = readableStreamFromReader(file);
await fetch("https://example.com/", {
method: "POST",
body: readableStream,
});