Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=fetch&page=573&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=fetch

Returns an array of strings in format "username" or "username/projectName"

Found 7881 results for "fetch"(1396ms)

libsqlstudiomain.tsx1 match

@steve_test_gpt•Updated 10 months ago
5const app = createApp();
6
7export default passwordAuth(app.fetch, {
8 verifyPassword: verifyToken,
9});

blobCommentsReactmain.tsx4 matches

@stevekrouse•Updated 10 months ago
11
12 useEffect(() => {
13 fetch("/comments")
14 .then(response => response.json())
15 .then(data => setComments(data));
19 e.preventDefault();
20 if (newComment.trim() !== "") {
21 const response = await fetch("/comments", {
22 method: "POST",
23 headers: { "Content-Type": "application/json" },
31
32 const handleDelete = async (id) => {
33 const response = await fetch(`/comments/${id}/delete`, {
34 method: "POST",
35 });
114});
115
116export default app.fetch;

blobCommentDemomain.tsx1 match

@stevekrouse•Updated 10 months ago
45});
46
47export default app.fetch;

sqliteExplorerAppmain.tsx4 matches

@hunty•Updated 10 months ago
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 })));

duckdbExamplemain.tsx2 matches

@hamilton•Updated 10 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let duckdbExample = (async () => {
4 async function createWorker(url: string) {
5 const workerScript = await fetch(url);
6 const workerURL = URL.createObjectURL(await workerScript.blob());
7 return new Worker(workerURL, { type: "module" });

duckdbExampleREADME.md1 match

@hamilton•Updated 10 months ago
1# DuckDB
2
3[DuckDB](https://duckdb.org/) works on Val Town, with only one small tweak! We're basically using DuckDB in the same way you'd use it with a browser - using the WASM package with its dependencies fetched from [jsdelivr](https://www.jsdelivr.com/).
4
5The only trick is to create the worker ourselves rather than using `duckdb.createWorker`. DuckDB's built-in createWorker method doesn't specify a worker type, which causes `type` to default to `classic`, and Deno (our runtime) doesn't support classic workers.

webPerformancemain.tsx1 match

@iamseeley•Updated 10 months ago
13async function measurePerformance(url) {
14 const start = Date.now();
15 const response = await fetch(url);
16 const ttfb = Date.now() - start;
17

fetchJSONmain.tsx5 matches

@stevekrouse•Updated 10 months ago
1import { normalizeURL } from "https://esm.town/v/stevekrouse/normalizeURL";
2
3export const fetchJSON = async (
4 url: string | URL,
5 options?: RequestInit & {
6 bearer?: string;
7 fetch?: typeof fetch;
8 },
9) => {
17 headers.set("traceparent", traceparent);
18 }
19 let fetch = options?.fetch ?? globalThis.fetch;
20 let resp = await fetch(normalizeURL(url), {
21 redirect: "follow",
22 ...options,
28 }
29 catch (e) {
30 throw new Error(`fetchJSON error: ${e.message} in ${url}\n\n"${text}"`);
31 }
32};

nasaImageDetailsmain.tsx2 matches

@wallek•Updated 10 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export const nasaImageDetails = async () => {
4 const nasaAPOD = await fetchJSON("https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY");
5 let nasaImageHtml = nasaAPOD.hdurl
6 ? `<img width="100%" src="${nasaAPOD.hdurl}"/>`

getYenPriceCronmain.tsx6 matches

@kayla_lin•Updated 10 months ago
1import { blob } from "https://esm.town/v/std/blob";
2import { fetch } from "https://esm.town/v/std/fetch";
3import xml2js from "npm:xml2js";
4
5async function fetchHistoricData() {
6 const currentDate = new Date();
7 const promises = [];
14 `https://www.floatrates.com/historical-exchange-rates.html?operation=rates&pb_id=1462&page=historical&currency_date=${formattedDate}&base_currency_code=JPY&format_type=xml`;
15
16 const fetchPromise = fetch(url)
17 .then((response) => {
18 if (!response.ok) {
40 .catch((error) => {
41 console.error(
42 "There has been a problem with your fetch operation:",
43 error,
44 );
46 });
47
48 promises.push(fetchPromise);
49 }
50
61
62export default async function(interval: Interval) {
63 const history = await fetchHistoricData();
64
65 await blob.setJSON("daily", history);

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago