1# `resilientFetch`: faster @std/fetch
2Try to fetch unproxied first, and fall back to proxied fetch if that fails.
1/** @jsxImportSource https://esm.sh/react */
2import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=46";
3import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
4import tailwindURL from "https://esm.town/v/stevekrouse/tailwindURL";
5import { renderToString } from "npm:react-dom/server";
6
7export const reactExample = modifyFetchHandler(async (request: Request) => {
8 const url = new URL(request.url);
9 if (url.pathname === "/favicon.ico") return new Response(null, { status: 404 });
1This is an example call of @stevekrouse/insecureFetch
2
3Migrated from folder: Archive/insecureSSLCertExample
13
14const url = "https://unpkg.com/@antonz/lua-wasi/dist/lua.wasm";
15const result = await WASI.start(fetch(url), {
16 args: ["lua", "/program.lua"],
17 stdout: (out) => console.log(out),
131 );
132});
133export default signInWithValTown(app.fetch);
5 for (const urlMatch of cssString.matchAll(urlRegex)) {
6 const originalUrl = urlMatch[1];
7 const response = await fetch(originalUrl);
8 const data = new Uint8Array(await response.arrayBuffer());
9 result = result.replace(
26 let fontCss = "";
27 try {
28 const r = await fetch(
29 "https://fonts.googleapis.com/css2?family="
30 + encodeURIComponent("IBM Plex Sans:wght@600")
10 profileImageUrl: string;
11}> =>
12 await (await fetch(`${API_URL}/v1/users/${id}`, {
13 headers: token
14 ? {
9 if ("valName" in params && params.token)
10 headers.Authorization = `Bearer ${params.token}`;
11 return await (await fetch(url, { headers })).json();
12}
13type UserParams = {
3
4async function execute(statement: InStatement): Promise<ResultSet> {
5 const resp = await fetch("https://sqlite-execute.web.val.run", {
6 method: "POST",
7 body: JSON.stringify({
10 const table = stripAnsi(renderTable(zip(res)));
11
12 const resp = await fetch("https://sourcecodeshots.com/api/image", {
13 method: "POST",
14 headers: {