Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 1.1 KB

README.md

File metadata and controls

48 lines (34 loc) · 1.1 KB

REST Client with Configurable Proxy for Deno

CI deno doc

This repository is currently experimental.

hello.json

{"text": "Hello"}

example.ts

import { exchange } from "https://raw.githubusercontent.com/chibat/rest_client_with_proxy/master/rest_client.ts";

const response = await exchange(
  {
    request: {
      url:
        "https://raw.githubusercontent.com/chibat/rest_client_with_proxy/master/test/hello.json",
    },
    proxy: {
      hostname: "proxy-server.example.com",
      port: 3128,
      credentials: { name: "user1", password: "test" },
    },
  },
);

type ResponseType = { text: string };

const responseText = response.json<ResponseType>().text;

console.log(responseText);

Execute

$ deno cache --reload example.ts
$ deno run --allow-net --unstable example.ts
Hello