189 code: newCode,
190 });
191 fetch('/save', { method: "POST", body }).then(() => {
192 document.getElementById('code-input-hidden').value = newCode;
193 document.getElementById('preview-iframe').src += '';
505 app.post("/", mainHandler);
506
507 return passwordAuth(app.fetch, { verifyPassword: verifyToken });
508}
14const table = "replace-me-abc123-xyz456";
15
16// 4. Implement row fetching using an API or a library:
17//
18// For example, you could call an API in a loop, using yield for each
48}
49
50// Handles calling fetch, checking for API errors
51function fetchGlide<A>(
52 method: "GET" | "POST" | "PUT",
53 url: string,
57 const { token } = yield* getGlide;
58 const result = yield* Effect.tryPromise(() =>
59 fetch(url, {
60 method,
61 headers: {
67 ).pipe(
68 Effect.tap(Effect.annotateCurrentSpan({ method, url })),
69 Effect.withLogSpan("fetchGlide"),
70 );
71
81 Effect.catchTag(
82 "UnknownException",
83 () => new GlideError({ message: "Could not fetch" }),
84 ),
85 );
102 rows = rows.map(removeUnsupportedColumnTypes);
103 }
104 const results = yield* fetchGlide<PutResult>("PUT", url, {
105 rows,
106 schema: { columns: [] },
124 const url = `${baseUrl}/stashes/${id}/${serial}`;
125 yield* Effect.logDebug(`postStash ${serial}`);
126 yield* fetchGlide("POST", url, rows);
127 return { $stashID: id };
128 }).pipe(
161 const stream = Stream.fromAsyncIterable(
162 // We buffer the rows into larger chunks
163 // because many APIs only fetch small chunks (e.g. 100)
164 // records at a time.
165 bufferAsyncIterable(getRows()),
190 code: newCode,
191 });
192 fetch('/save', { method: "POST", body }).then(() => {
193 document.getElementById('code-input-hidden').value = newCode;
194 document.getElementById('preview-iframe').src += '';
497 app.post("/", mainHandler);
498
499 return passwordAuth(app.fetch, { verifyPassword: verifyToken });
500}
190 code: newCode,
191 });
192 fetch('/save', { method: "POST", body }).then(() => {
193 document.getElementById('code-input-hidden').value = newCode;
194 document.getElementById('preview-iframe').src += '';
497 app.post("/", mainHandler);
498
499 return passwordAuth(app.fetch, { verifyPassword: verifyToken });
500}
9 let reason: string;
10 try {
11 const res = await fetch(URL, { redirect: "follow" });
12 if (res.status !== 200) {
13 reason = `(status code: ${res.status})`;
15 }
16 } catch (e) {
17 reason = `couldn't fetch: ${e}`;
18 ok = false;
19 }
4
5const getCryptoPrices = async () => {
6 const response = await fetch(
7 "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin,ethereum,dogecoin,solana,binancecoin,ripple,pepe",
8 {
52 const telegramSendUrl =
53 `https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage?chat_id=${TELEGRAM_CHAT_ID}&parse_mode=HTML&disable_notification=true&text=${text}`;
54 await fetch(telegramSendUrl);
55};
56
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=6";
2import { load } from "npm:cheerio";
3
4const html = await fetchText(
5 "https://www.gov.uk/government/publications/migrants-detected-crossing-the-english-channel-in-small-boats/migrants-detected-crossing-the-english-channel-in-small-boats-last-7-days",
6);
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));
1# Fetch Template
2Example template to quickly get started with a backend for Fetch in Framer.