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=262&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 2732 results for "fetch"(386ms)

cronLoggermain.tsx2 matches

@nbbaier•Updated 9 months ago
2import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
3import { sqlite } from "https://esm.town/v/std/sqlite?v=6";
4import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=45";
5import { refs } from "https://esm.town/v/stevekrouse/refs?v=11";
6
26 headers["Authorization"] = `Bearer ${token}`;
27 }
28 const { id } = await fetchJSON(`${API_URL}/v1/alias/${userHandle}/${valName}`, { headers });
29
30 const table_name = "cron_evals";

fetchJSONmain.tsx5 matches

@maxm•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};

uptimemain.tsx2 matches

@stevekrouse•Updated 10 months ago
11 const start = performance.now();
12 try {
13 const res = await fetch(url);
14 end = performance.now();
15 status = res.status;
22 } catch (e) {
23 end = performance.now();
24 reason = `couldn't fetch: ${e}`;
25 ok = false;
26 console.log(`Website down (${url}): ${reason} (${end - start}ms)`);

staticChessmain.tsx2 matches

@tmcw•Updated 10 months ago
11
12 constructor() {}
13 async fetch(req: Request): Promise<Response> {
14 if (new URL(req.url).pathname === "/robots.txt") {
15 return new Response("User-agent: *\nDisallow: /");
232const sc = new StaticChess();
233
234export default analyticsHandlerWrapper(sc.fetch.bind(sc));

test_explorermain.tsx1 match

@maxm•Updated 10 months ago
3export { Test } from "https://esm.town/v/pomdtr/test";
4
5export default router.fetch;

blobbyFacemain.tsx15 matches

@stevekrouse•Updated 10 months ago
2import { blobby } from "https://esm.town/v/yawnxyz/blobby";
3import { fileTypeFromBuffer } from 'npm:file-type';
4import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
5import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth?v=74";
6
66
67
68// Endpoint to fetch blob by key
69app.get("/blob/:key", async (c) => {
70 const key = c.req.param('key');
193 this.blobs[key] = {isLoading: true};
194
195 const response = await fetch('/blob/' + key);
196 const contentType = response.headers.get('Content-Type');
197 blob.type = contentType || 'text/plain';
223 let blob = this.blobs[key];
224 try {
225 const response = await fetch('/create/' + key, {
226 method: 'POST',
227 headers: {
247
248 // Send a delete request to the server
249 const response = await fetch('/delete/' + key, { method: 'GET' });
250
251 // Check the response status
313
314 try {
315 const response = await fetch('/upload/' + key, {
316 method: 'POST',
317 body: formData,
338
339 try {
340 const response = await fetch('/uploadUrl' + '?key=' + key + '&url=' + url);
341
342 if (!response.ok) {
361 if (!this.newKeyName) return;
362 try {
363 const response = await fetch('/rename?key='+key+'&newKey='+this.newKeyName);
364 if (!response.ok) {
365 throw new Error('Failed to rename blob');
526 async loadBlob() {
527 this.isLoading = true;
528 const response = await fetch('/blob/' + this.key);
529 const contentType = response.headers.get('Content-Type');
530 this.blobType = contentType || 'text/plain';
550 async updateCreate() {
551 try {
552 const response = await fetch('/create/' + this.key, {
553 method: 'POST',
554 headers: {
573
574 try {
575 const response = await fetch('/upload/' + this.key, {
576 method: 'POST',
577 body: formData,
593 if (this.uploadUrl) {
594 try {
595 const response = await fetch('/uploadUrl?key=' + this.key + '&url=' + this.uploadUrl);
596
597 if (!response.ok) {
610 if (!this.newKeyName) return;
611 try {
612 const response = await fetch('/rename?key=' + this.key + '&newKey=' + this.newKeyName);
613 if (!response.ok) {
614 throw new Error('Failed to rename blob');
707
708
709// export default app.fetch;
710export default passwordAuth(app.fetch, {
711 // password: "123", // Deno.env.get("AUTH_TEST"),
712});

counterTownmain.tsx2 matches

@stevekrouse•Updated 10 months ago
1/** @jsxImportSource npm:hono@3/jsx */
2import { sqlite } from "https://esm.town/v/std/sqlite?v=6";
3import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
4import { Hono } from "npm:hono";
5
50
51const app = new Hono();
52export default reloadOnSaveFetchMiddleware(counterTownMiddleware(app.fetch));
53app.get("/", async (c) => {
54 return c.html(

blushAardwolfmain.tsx3 matches

@stevekrouse•Updated 10 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3const blog_bookmark = await fetchJSON(
4 "https://datasette.simonwillison.net/simonwillisonblog/blog_blogmark.json?_labels=on&_shape=objects",
5);
6
7const blog_quotation = await fetchJSON(
8 "https://datasette.simonwillison.net/simonwillisonblog/blog_quotation.json?_labels=on&_shape=objects",
9);

fuchsiaSnipemain.tsx1 match

@tmcw•Updated 10 months ago
1export default async function(req: Request): Promise<Response> {
2 const response = await fetch("http://worldtimeapi.org/api/timezone/America/New_York")
3 const timeData = await response.json()
4

imageMagickWasmExamplemain.tsx1 match

@maxm•Updated 10 months ago
7} from "https://esm.sh/@imagemagick/magick-wasm";
8
9const resp = await fetch("https://esm.sh/@imagemagick/magick-wasm@0.0.29/dist/magick.wasm");
10const wasmBytes = await resp.arrayBuffer();
11

fetchPaginatedData2 file matches

@nbbaier•Updated 6 days ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago