deno.land / std@0.157.0 / examples / curl.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
/** Basic CLI to fetch URLs and log body to console. * * @module */
const url_ = Deno.args[0];const res = await fetch(url_);
// TODO(ry) Re-enable streaming in this example.// Originally we did: await Deno.copy(res.body, Deno.stdout);// But maybe more JS-y would be: res.pipeTo(Deno.stdout);
const body = new Uint8Array(await res.arrayBuffer());await Deno.stdout.write(body);
std

Version Info

Tagged at
a year ago