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%20%22Optional%20title%22?q=fetch&page=700&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 9515 results for "fetch"(3221ms)

memeGeneratormain.tsx1 match

@stevekrouse•Updated 8 months ago
30
31 useEffect(() => {
32 fetch("/templates")
33 .then(response => response.json())
34 .then(data => setTemplates(data));

isMyWebsiteDownmain.tsx2 matches

@shreyasmakes•Updated 8 months ago
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 }

likelyPinkPuffinmain.tsx5 matches

@stevedylandev•Updated 8 months ago
2 * This val creates a cron job that sends an email with recent Stack Overflow posts
3 * mentioning various file upload-related topics.
4 * It uses the Stack Exchange API to fetch recent questions and the Val Town email API to send the digest.
5 */
6
16];
17
18// Function to fetch recent questions from Stack Overflow for multiple topics
19async function fetchRecentQuestions(): Promise<StackExchange.Question[]> {
20 const allQuestions: StackExchange.Question[] = [];
21
22 for (const topic of TOPICS) {
23 const response = await fetch(
24 `https://api.stackexchange.com/2.3/questions?order=desc&sort=creation&site=stackoverflow&filter=withbody&tagged=${topic}&pagesize=5`,
25 );
48 const { email } = await import("https://esm.town/v/std/email");
49
50 const questions = await fetchRecentQuestions();
51 const htmlContent = formatQuestionsHtml(questions);
52

codeOnValTownREADME.md6 matches

@Serizon•Updated 8 months ago
11Here are 2 different ways to add the "Code on Val Town" ribbon:
12
13### 1. Wrap your fetch handler (recommended)
14
15```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
18
19export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20 return html(`<h2>Hello world!</h2>`);
21});
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
55
58You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
59
60- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
62
64
65```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67 .github-fork-ribbon {
68 display: none !important;

codeOnValTownmain.tsx3 matches

@Serizon•Updated 8 months ago
37
38/**
39 * @param handler Fetch handler
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},
52}
53
54export default modifyFetchHandler;

umapmain.tsx3 matches

@ejfox•Updated 8 months ago
142 <h3>Basic Example:</h3>
143 <pre>
144fetch("https://ejfox-umap.web.val.run/", {
145 method: "POST",
146 headers: { "Content-Type": "application/json" },
183const embeddings = await getEmbeddings(texts);
184
185fetch("/", {
186 method: "POST",
187 headers: { "Content-Type": "application/json" },
209 };
210
211 fetch("https://ejfox-umap.web.val.run", {
212 method: "POST",
213 headers: { "Content-Type": "application/json" },

zod_demo_frontendmain.tsx1 match

@stevekrouse•Updated 8 months ago
19
20 // Send data to server
21 const response = await fetch("/register", {
22 method: "POST",
23 headers: { "Content-Type": "application/json" },

blob_adminmain.tsx2 matches

@lithrel•Updated 8 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";
137});
138
139export default modifyFetchHandler(passwordAuth(app.fetch));

weatherGPTmain.tsx1 match

@sarfrazkhan18•Updated 8 months ago
4let location = "brooklyn ny";
5let lang = "en";
6const weather = await fetch(
7 `https://wttr.in/${location}?lang=${lang}&format=j1`,
8).then(r => r.json());

umbrellaRemindermain.tsx2 matches

@sarfrazkhan18•Updated 8 months ago
1import { email } from "https://esm.town/v/std/email?v=9";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { nominatimSearch } from "https://esm.town/v/stevekrouse/nominatimSearch";
4import { weatherGovGrid } from "https://esm.town/v/stevekrouse/weatherGovGrid";
14 lon,
15 });
16 let { properties: { periods } } = await fetchJSON(
17 grid.forecastHourly,
18 );

agentplex-deal-flow-email-fetch1 file match

@anandvc•Updated 6 hours ago

proxyFetch2 file matches

@vidar•Updated 2 days ago