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/$%7Bart_info.art.src%7D?q=fetch&page=1042&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 13095 results for "fetch"(2066ms)

virtualPetSimmain.tsx4 matches

@muhammad_owais_warsi•Updated 9 months ago
21
22 useEffect(() => {
23 fetchPet();
24 }, []);
25
26 const fetchPet = async () => {
27 const response = await fetch("/pet");
28 const data = await response.json();
29 setPet(data);
32
33 const interact = async (action) => {
34 const response = await fetch("/interact", {
35 method: "POST",
36 headers: { "Content-Type": "application/json" },

KidsCodingDameDinoAdventuremain.tsx5 matches

@jbwinters•Updated 9 months ago
81
82 useEffect(() => {
83 fetchHighScores();
84 }, []);
85
86 const fetchHighScores = async () => {
87 const response = await fetch('/highscores');
88 const scores = await response.json();
89 setHighScores(scores);
250
251 // Submit high score
252 await fetch('/highscore', {
253 method: 'POST',
254 headers: { 'Content-Type': 'application/json' },
255 body: JSON.stringify({ score: newScore })
256 });
257 fetchHighScores();
258 }, [grid, moves, score]);
259

honoJsxHtmlTemplatesmain.tsx1 match

@yawnxyz•Updated 9 months ago
44})
45
46export default app.fetch

getWeathermain.tsx2 matches

@escalona•Updated 9 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function getWeather(location: string): Promise<WeatherResponse> {
4 return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}
6

sunsetNYCalendarmain.tsx1 match

@ejfox•Updated 9 months ago
107async function getSunsetTime(date: Date): Promise<Date> {
108 const formattedDate = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`;
109 const response = await fetch(`https://api.sunrise-sunset.org/json?lat=40.7128&lng=-74.0060&date=${formattedDate}&formatted=0`);
110
111 if (!response.ok) {

slackScoutmain.tsx8 matches

@sarahxc•Updated 9 months ago
20 for (const topic of KEYWORDS) {
21 const results = await Promise.allSettled([
22 fetchHackerNewsResults(topic),
23 fetchTwitterResults(topic),
24 fetchRedditResults(topic),
25 ]);
26
49}
50
51// Fetch Hacker news, Twitter, and Reddit results
52async function fetchHackerNewsResults(topic: string): Promise<Website[]> {
53 return hackerNewsSearch({
54 query: topic,
58}
59
60async function fetchTwitterResults(topic: string): Promise<Website[]> {
61 return twitterSearch({
62 query: topic,
67}
68
69async function fetchRedditResults(topic: string): Promise<Website[]> {
70 return redditSearch({ query: topic });
71}
84 }
85
86 const response = await fetch(slackWebhookUrl, {
87 method: "POST",
88 headers: { "Content-Type": "application/json" },

twitterSearchmain.tsx2 matches

@alexdphan•Updated 9 months ago
99 author = authorResponse.data;
100 } catch (error) {
101 console.error(`Error fetching author for tweet ${tweet.id}: ${error.message}`);
102 }
103 const tweetUrl = `https://twitter.com/${author?.username || "user"}/status/${tweet.id}`;
119 return allTweets;
120 } catch (error) {
121 console.error("Error fetching tweets:", error);
122 throw error;
123 }

hackerNewsSearchmain.tsx1 match

@alexdphan•Updated 9 months ago
129 const result = await dateConverterFunction({ relativeDate });
130
131 // Check if the result is a Response object (from a potential fetch call)
132 if (result instanceof Response) {
133 // If it's a Response, extract and return its text content

telegramValTownBotWebhookmain.tsx3 matches

@stevekrouse•Updated 9 months ago
1import { email } from "https://esm.town/v/std/email?v=9";
2import { fetch } from "https://esm.town/v/std/fetch";
3import { set } from "https://esm.town/v/std/set?v=11";
4import { isValidURL } from "https://esm.town/v/stevekrouse/isValidURL";
60 chat.webhook = url;
61 try {
62 await fetch(url, { method: "POST", body: JSON.stringify(body) });
63 await messageBack(
64 "Webhook setup!\n\nWe forwarded your last message to your webhook as a test",
103 if (chat.webhook) {
104 console.log("Sending message to webhook", chat.webhook);
105 await fetch(chat.webhook, {
106 method: "POST",
107 body: JSON.stringify(body),

buttonmain.tsx5 matches

@stevekrouse•Updated 9 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export default async function server(req: Request): Promise<Response> {
7 for (const urlMatch of cssString.matchAll(urlRegex)) {
8 const originalUrl = urlMatch[1];
9 const response = await fetch(originalUrl);
10 const data = new Uint8Array(await response.arrayBuffer());
11 result = result.replace(
29 let fontCss = "";
30 try {
31 const r = await fetch(
32 "https://fonts.googleapis.com/css2?family=" +
33 encodeURIComponent("IBM Plex Sans:wght@600") +
37 );
38 if (!r.ok)
39 throw new Error("Failed to fetch font CSS");
40 fontCss = await inlineUrls(await r.text());
41 }
42 catch (e) {
43 console.error("Error fetching font CSS:", e);
44 }
45

fetch-socials4 file matches

@welson•Updated 3 days ago
fetch and archive my social posts

fetchRssForSubcurrent2 file matches

@ashryanio•Updated 3 days ago