10 let status: number;
11 try {
12 const res = await fetch(URL, { redirect: "follow" });
13 if (res.status !== 200) {
14 reason = `(status code: ${res.status})`;
17 }
18 } catch (e) {
19 reason = `couldn't fetch: ${e}`;
20 ok = false;
21 }
61 attachments?: AttachmentData[];
62}) => {
63 let result = await fetch(
64 `${API_URL}/v1/email`,
65 {
1import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
2import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=6";
3import { html } from "https://esm.town/v/stevekrouse/html?v=5";
4import { Readability } from "npm:@mozilla/readability";
89 }
90
91 let body = await fetchText(articleUrl);
92
93 let doc = new JSDOM(body);
1Migrated from folder: a0_forks/fetchText
1Migrated from folder: a0_forks/fetchJSON
14export async function getCertificates(domain: string) {
15 const url = `https://crt.sh/json?q=${domain}`;
16 const response = await fetch(url);
17 const certificates: Certificate[] = await response.json();
18 const domains = [...new Set(certificates.map(el => el.common_name))];
1Migrated from folder: a2_shared/fetch_example
1# Proxied fetch - https://docs.val.town/std/fetch
2
3Migrated from folder: a0_forks/fetch
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
2
3const url = "https://assignment-api.uspto.gov/patent/basicSearch?query=1234567&fields=main&rows=20";
4const proxyURL = new URL("https://unsecure-fetch.val-town.workers.dev");
5proxyURL.searchParams.set("url", url);
6
7// console.debug("proxyUrl: %s", proxyURL);
8// ==> proxyUrl: https://unsecure-fetch.val-town.workers.dev/?url=https%3A%2F%2Fassignment-api.uspto.gov%2Fpatent%2FbasicSearch%3Fquery%3D1234567%26fields%3Dmain%26rows%3D20
9console.log(await fetchText(proxyURL.href));
1# Insecure SSL Cert Fetch
2
3If you need to make a fetch request to a website with a dubious or non-standard SSL certificate, you can use this proxy we made on Cloudflare workers (which doesn't verify SSL certs): https://unsecure-fetch.val-town.workers.dev/
4
5Example usage below.