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=259&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 2746 results for "fetch"(1162ms)

oliveGardenCharmain.tsx11 matches

@charmaine•Updated 6 months ago
10
11 useEffect(() => {
12 fetchCoworkers();
13 fetchPeopleBrought();
14 }, []);
15
16 const fetchCoworkers = async () => {
17 const response = await fetch("?action=list");
18 const data = await response.json();
19 setCoworkers(data);
20 };
21
22 const fetchPeopleBrought = async () => {
23 const response = await fetch("?action=getPeopleBrought");
24 const data = await response.json();
25 setPeopleBrought(data.peopleBrought);
30 if (!newCoworker.trim()) return;
31
32 await fetch("?action=add", {
33 method: "POST",
34 body: JSON.stringify({ name: newCoworker }),
35 });
36 setNewCoworker("");
37 fetchCoworkers();
38 };
39
41 const value = parseInt(e.target.value) || 1;
42 setPeopleBrought(value);
43 await fetch("?action=updatePeopleBrought", {
44 method: "POST",
45 body: JSON.stringify({ peopleBrought: value }),
48
49 const deleteCoworker = async (id) => {
50 await fetch("?action=delete", {
51 method: "POST",
52 body: JSON.stringify({ id }),
53 });
54 fetchCoworkers();
55 };
56

twitterRecentMentionsmain.tsx3 matches

@charmaine•Updated 6 months ago
1// This val fetches recent tweets about @SnapAR or Lens Studio
2// Updated to use Social Data instead of Twitter API
3
12 return retResponse(data.tweets);
13 } catch (error) {
14 console.error("Error fetching posts:", error);
15 return new Response(JSON.stringify({ error: "Failed to fetch posts", details: error.message }), {
16 status: 500,
17 headers: { "Content-Type": "application/json" },

socialDataUpdatemain.tsx4 matches

@charmaine•Updated 6 months ago
1// This val fetches recent tweets about @SnapAR or Lens Studio, removes duplicates,
2// and displays them as embedded tweets with preview images on a dark background.
3// Updated to use Social Data instead of Twitter API
5import { socialDataSearch } from "https://esm.town/v/stevekrouse/socialDataSearch?v=5";
6
7// This val fetches recent social media posts about @SnapAR or Lens Studio using socialDataSearch,
8// and displays them as embedded posts with preview images on a dark background.
9
15 return retResponse(data.tweets);
16 } catch (error) {
17 console.error("Error fetching posts:", error);
18 return new Response(JSON.stringify({ error: "Failed to fetch posts", details: error.message }), {
19 status: 500,
20 headers: { "Content-Type": "application/json" },

valiantSalmonWarblermain.tsx1 match

@maxm•Updated 6 months ago
30 // handler may only run once now, where in the old runtime it
31 // ran on every request. To migrate your code, you may have to
32 // move some code that was outside your fetch handler to run inside it.
33 // </p>
34

valiantSalmonWarblermain.tsx1 match

@stevekrouse•Updated 6 months ago
22 handler may only run once now, where in the old runtime it
23 ran on every request. To migrate your code, you may have to
24 move some code that was outside your fetch handler to run inside it.
25 </p>
26

tvshowsmain.tsx2 matches

@tmcw•Updated 6 months ago
1import { dataToRSS } from "https://esm.town/v/Glench/dataToRSS"
2import { fetch } from "https://esm.town/v/std/fetch"
3import process from "node:process"
4
28 const show_id = TV_SHOWS_WATCHED[i]
29 const url = `https://api.themoviedb.org/3/tv/${show_id}?api_key=${process.env.tmdb_api_key}`
30 const resp = await fetch(url)
31 const show = await resp.json()
32 data.push(show)

getAppleDevicemain.tsx2 matches

@tmcw•Updated 6 months ago
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=5"
2
3export async function getAppleDevice(req: Request) {
4 const deviceId = new URL(req.url).searchParams.get("search_keywords") as string
5 if (!deviceId) return Response.json("Please provide a search_keywords query parameter")
6 const html = await fetchText(
7 `https://everymac.com/ultimate-mac-lookup/?search_keywords=${encodeURI(deviceId)}`,
8 )

createGitHubContribGraphmain.tsx12 matches

@tmcw•Updated 7 months ago
184
185 useEffect(() => {
186 fetchContributions()
187 }, [])
188
189 const fetchContributions = async () => {
190 setError(null)
191 setContributionData(null)
192 setUserData(null)
193 try {
194 const response = await fetch("/contributions", {
195 method: "POST",
196 headers: { "Content-Type": "application/json" },
197 body: JSON.stringify({ username }),
198 })
199 if (!response.ok) throw new Error("Failed to fetch contributions")
200 const data = await response.json()
201 console.log("Fetched data:", data)
202 setContributionData(data.contributionCalendar)
203 setUserData(data.user)
204 } catch (err) {
205 console.error("Error fetching contributions:", err)
206 setError(err.message)
207 }
237 const handleKeyPress = (event) => {
238 if (event.key === "Enter") {
239 fetchContributions()
240 }
241 }
309 placeholder="Enter GitHub username"
310 />
311 <button onClick={fetchContributions}>Fetch Commits</button>
312 </div>
313 {error && <p className="error">{error}</p>}
368 if (request.method === "POST" && new URL(request.url).pathname === "/contributions") {
369 const { username } = await request.json()
370 const contributionData = await fetchGitHubContributions(username)
371 return new Response(JSON.stringify(contributionData), {
372 headers: { "Content-Type": "application/json" },
395}
396
397async function fetchGitHubContributions(username: string) {
398 const query = `
399 query($username: String!) {
417 `
418
419 const response = await fetch("https://api.github.com/graphql", {
420 method: "POST",
421 headers: {
427
428 if (!response.ok) {
429 throw new Error("Failed to fetch GitHub data")
430 }
431

iframeGridInfinitemain.tsx2 matches

@maxm•Updated 7 months ago
142 setIsLoading(true);
143 try {
144 const response = await fetch('/api/submit-url', {
145 method: 'POST',
146 headers: {
162 const loadUrlDatabase = async () => {
163 try {
164 const response = await fetch('/api/load-urls');
165 if (!response.ok) throw new Error('Failed to load URLs');
166 const loadedUrls = await response.json();

XKCDComicOfTheDaymain.tsx3 matches

@wolf•Updated 7 months ago
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=6";
2import { load } from "npm:cheerio";
3
4export default async function(req: Request): Promise<Response> {
5 const response = await fetchText("https://xkcd.com/");
6 const $ = load(response);
7 const image = $("div#comic img").attr("src");
8 return new Response(await (await fetch(image)).arrayBuffer());
9}

fetchPaginatedData2 file matches

@nbbaier•Updated 6 days ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago