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=629&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 8476 results for "fetch"(2539ms)

ReadmeWritermain.tsx3 matches

@willthereader•Updated 10 months ago
1import { type WriterOptions } from "https://esm.town/v/nbbaier/WriterOptions";
2import { fetch } from "https://esm.town/v/std/fetch?v=4";
3import OpenAI, { type ClientOptions } from "npm:openai";
4
32 private async getVal(username: string, valName: string) {
33 try {
34 const res = await fetch(`https://api.val.town/v1/alias/${username}/${valName}`, {
35 method: "GET",
36 headers: {
72 private async updateReadme(id: string, readme: string) {
73 try {
74 const res = await fetch(`https://api.val.town/v1/vals/${id}`, {
75 method: "PUT",
76 headers: {

sqliteExplorerAppmain.tsx4 matches

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

pubmedmain.tsx4 matches

@yawnxyz•Updated 10 months ago
1import { Hono } from "npm:hono@3";
2import { cors } from "npm:hono/cors";
3import { fetch } from "https://esm.town/v/std/fetch";
4
5const app = new Hono();
10// PubMed search function (modified to accept more parameters)
11async function pubmedSearch(query, userId, additionalParams = {}) {
12 const url = 'https://www.pubmedisearch.com/api/fetch_articles';
13 const options = {
14 method: 'POST',
30
31 try {
32 const response = await fetch(url, options);
33 if (!response.ok) {
34 throw new Error(`HTTP error! status: ${response.status}`);
79});
80
81export default app.fetch;
82export { pubmedSearch };

honoJsPyodidemain.tsx1 match

@tfayyaz•Updated 10 months ago
88});
89
90export default app.fetch;

getValsContextWindowmain.tsx7 matches

@janpaul123•Updated 10 months ago
69 );
70 });
71 export default app.fetch;`,
72 },
73 {
129 {
130 prompt: "Write a val that accesses environment variables",
131 code: `const res = await fetch("${API_URL}/v1/me", {
132 headers: {
133 Authorization: \`Bearer \${Deno.env.get("valtown")}\`,
141 code: `import process from "node:process";
142
143 const res = await fetch("${API_URL}/v1/me", {
144 headers: {
145 Authorization: \`Bearer \${process.env.valtown}\`,
165 code: `import cheerio from "npm:cheerio";
166
167 const response = await fetch("https://example.com");
168 const body = await response.text();
169 const $ = cheerio.load(body);
453 {
454 role: "user",
455 content: "Write a val that fetches the weather in Brooklyn, NY",
456 },
457 {
458 role: "assistant",
459 content:
460 "```ts\nexport default async function(req: Request): Promise<Response> {\n const apiKey = Deno.env.get(\"METEO_KEY\");\n const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=40.6782&longitude=-73.9442&hourly=temperature_2m&current_weather=true&apikey=${apiKey}`;\n\n const response = await fetch(apiUrl);\n const weatherData = await response.json();\n\n return new Response(JSON.stringify(weatherData), { headers: { \"Content-Type\": \"application/json\" } });\n}\n```",
461 },
462 {
467 role: "assistant",
468 content:
469 "```ts\n/** @jsxImportSource npm:hono@3/jsx */\nimport { Hono } from \"npm:hono\";\n\nconst app = new Hono();\napp.get(\"/\", async (c) => {\n return c.html(\n <div>\n <form>\n Your name: <input type=\"text\" name=\"name\" /> <input type=\"submit\" />\n </form>\n Hello {c.req.query(\"name\")}\n </div>,\n );\n});\nexport default app.fetch;\n```",
470 },
471 ...templatePrompts,

blob_adminmain.tsx2 matches

@janpaul123•Updated 10 months ago
1/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
5import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
133});
134
135export default modifyFetchHandler(passwordAuth(app.fetch));

valwritermain.tsx6 matches

@janpaul123•Updated 10 months ago
2import { updateValByName } from "https://esm.town/v/nbbaier/updateValByName?v=14";
3import { basicAuth } from "https://esm.town/v/pomdtr/basicAuth?v=62";
4import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
5import { chat } from "https://esm.town/v/stevekrouse/openai";
6import cronstrue from "npm:cronstrue";
19It stores each line of the poem in sqlite.
20It has a textbox that lets anyone input a new line to the poem.`,
21 content: await fetchText("https://esm.town/v/stevekrouse/poembuilder3?v=4"),
22 },
23 {
24 user: "an app that uses chatgpt to convert natural language to cron syntax",
25 content: await fetchText("https://esm.town/v/stevekrouse/cron2"),
26 },
27];
29const app = new Hono();
30
31export default basicAuth(app.fetch);
32app.get("/", async (c) => {
33 const example = examples[Math.floor(Math.random() * examples.length)];
98 Write ONLY Deno TypeScript.
99
100 If you use Hono, use \`export default app.fetch;\` to start the server.
101
102 Only use web standard fetch.
103 // Our library for SQLite
104 import { sqlite } from "https://esm.town/v/std/sqlite";

spotifymain.tsx9 matches

@hunty•Updated 10 months ago
2import { home, scopesRoute } from "https://esm.town/v/hunty/spotify_helpers";
3import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
4import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
5import { querystring } from "https://esm.town/v/stevekrouse/querystring";
6import { thisWebURL } from "https://esm.town/v/stevekrouse/thisWebURL";
25
26export let spotifyRequestToken = ({ client_id, client_secret, code, redirect_uri }) =>
27 fetchJSON("https://accounts.spotify.com/api/token", {
28 method: "POST",
29 body: querystring({
39
40export let spotifyRefreshToken = async ({ refresh_token, client_id, client_secret }) =>
41 fetch("https://accounts.spotify.com/api/token", {
42 method: "POST",
43 body: new URLSearchParams({
191
192 try {
193 const currentlyPlaying = await fetch("https://api.spotify.com/v1/me/player/currently-playing", {
194 method: "GET",
195 headers: {
207
208 if (!mostRecentTrack) {
209 const recentTracks = await fetch("https://api.spotify.com/v1/me/player/recently-played", {
210 method: "GET",
211 headers: {
220 }
221 catch (e) {
222 return c.json({ error: "Fetch Error" + e }, 500);
223 }
224});
232
233 try {
234 const playStateResponse = await fetch("https://api.spotify.com/v1/me/player?market=US", {
235 method: "GET",
236 headers: {
251 }
252 catch (e) {
253 return c.json({ error: "Fetch Error" + e }, 503);
254 }
255});
256
257export default app.fetch;

dailyPoemForSammain.tsx3 matches

@iamseeley•Updated 10 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3async function getRandomPoem() {
4 const response = await fetch("https://poetrydb.org/random");
5 const [poem] = await response.json();
6 return poem;
16 const message = `Daily Poem:\n\n${title}\nby ${author}\n\n${lines}`;
17
18 const response = await fetch('https://samwho-notify.web.val.run', {
19 method: 'POST',
20 headers: {

urlMetadatamain.tsx1 match

@yawnxyz•Updated 10 months ago
6 return metadata;
7 } catch (err) {
8 console.error('Error fetching metadata:', err);
9 return null;
10 }

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago