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/image-url.jpg?q=fetch&page=753&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 8438 results for "fetch"(922ms)

biliStreammain.tsx2 matches

@nishui•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { email } from "https://esm.town/v/std/email?v=9";
3import { set } from "https://esm.town/v/std/set?v=11";
24 for (let i = 0; i < idArray.length; i++) {
25 const id = idArray[i];
26 const request = fetch(
27 `https://api.live.bilibili.com/room/v1/Room/room_init?id=${id}`,
28 ).then((data) => data.json());

wttrJsonmain.tsx2 matches

@rwev•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function wttrJson(location: string) {
4 // https://github.com/chubin/wttr.in#json-output
5 return (await fetch(`https://wttr.in/${location}?format=j1`)).json();
6}

bggTestmain.tsx2 matches

@clayton•Updated 1 year ago
1import { fetchXML } from "https://esm.town/v/stevekrouse/fetchXML?v=3";
2
3export const bggTest = async function () {
4 const xml = await fetchXML(
5 "https://boardgamegeek.com/xmlapi2/plays?username=acciopatronus",
6 );

duckDbJsonmain.tsx2 matches

@neverstew•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { insertDataIntoDuckDb } from "https://esm.town/v/neverstew/insertDataIntoDuckDb";
3import { getDuckDB } from "https://esm.town/v/tmcw/getDuckDB?v=1";
5export const duckDbJson = (async () => {
6 const db = await getDuckDB();
7 const r = await fetch("https://jsonplaceholder.typicode.com/todos");
8 await insertDataIntoDuckDb(db, await r.json());
9 const c = await db.connect();

rawmain.tsx2 matches

@neverstew•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export async function raw(val: `@${string}.${string}`) {
4 const [owner, name] = val.slice(1).split(".") as string[];
5 return fetchJSON(
6 `https://api.val.town/v1/alias/${owner}/${name}`,
7 )

runmain.tsx2 matches

@neverstew•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function run(
10 const method = data ? "POST" : "GET";
11 const body = data ? JSON.stringify({ args: data }) : undefined;
12 const response = await fetch(url, { method, headers, body });
13 return await response.json();
14}

githubUsermain.tsx2 matches

@seflless•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Github profile
4export let githubUser = fetchJSON(
5 "https://api.github.com/users/stevekrouse"
6);

handleSanguineGithubWebhookmain.tsx7 matches

@nico•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import process from "node:process";
3
18 console.log("code: ", code);
19 try {
20 const gh_res = await fetch(
21 `https://github.com/login/oauth/access_token?code=${code}&client_id=${process.env.sanguineGithubClientId}&client_secret=${process.env.sanguineGithubClientSecret}`,
22 {
31 },
32 );
33 console.log("made it past fetch");
34 console.log("gh_res: ", gh_res);
35 if (!gh_res.ok) {
36 throw new Error(`Failed to fetch`);
37 }
38 const gh_res_json = await gh_res.json();
42 const accessToken = data?.access_token;
43 console.log("access_token: ", data);
44 // // Fetch user information using the access token
45 const userResponse: any = await fetch("https://api.github.com/user", {
46 headers: {
47 "Authorization": `Bearer ${accessToken}`,
55 }
56 catch (err) {
57 console.error("Error fetching access token or user data:", err);
58 res.status(500).send("Authentication failed");
59 }

fetchDOEMenumain.tsx3 matches

@tal•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3// https://www.schools.nyc.gov/docs/default-source/school-menus/2023-2024/september/pre-k---8-express-hot-lunch-menu
4//
5export let fetchDOEMenu: (opts: {schoolYear: `${number}-${number}`, month: string, menuType: string}) = (async ({schoolYear, month, menuType}) => {
6 const resp = await fetch(
7 `https://www.schools.nyc.gov/docs/default-source/school-menus/${schoolYear}/${month}/${menuType}`,
8 {

shittyValTownUImain.tsx2 matches

@vez•Updated 1 year ago
8 isInterval?: boolean;
9 }) =>
10 `fetch('https://api.val.town/eval/@vez.editVal(${JSON.stringify(body)})')`;
11 return res.send(`<h1>Shitty Val Town 2</h1>
12${(await getAllVals("@vez")).map(({ code, name }) => {
13 const editorId = `${name}-editor`;
14 const onClick = `(document.getElementById('${name}-button').textContent = 'save 🔄'), fetch('https://api.val.town/eval/@vez.editVal', { method: 'POST', body: JSON.stringify({ name: '${name}', code: document.getElementById('${editorId}').value })}).then(()=>(document.getElementById('${name}-button').textContent = 'save ✅'))`;
15 return `<h2>${name}</h2>
16<textarea id="${editorId}" rows="20" cols="120">${escapeHtml(

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago