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=462&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 7867 results for "fetch"(862ms)

getWeathermain.tsx2 matches

@hercialvitalis21•Updated 5 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

weatherGPTmain.tsx1 match

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

scraper_templatemain.tsx1 match

@vawogbemi•Updated 5 months ago
9 const variable: string = await blob.getJSON(blobKey) ?? "";
10
11 const response = await fetch(scrapeURL);
12 const body = await response.text();
13 const $ = cheerio.load(body);

get_gemini_modelsmain.tsx2 matches

@spinningideas•Updated 5 months ago
11 const API_KEY = process.env.GEMINI_API_KEY;
12
13 const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${API_KEY}`);
14
15 const data = await response.json();
22 return models;
23 } catch (error) {
24 console.error("Error fetching Gemini models:", error);
25 return [];
26 }

sqliteExplorerAppmain.tsx4 matches

@spinningideas•Updated 5 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 })));

accomplishedGoldUrialmain.tsx1 match

@Niranjna331022•Updated 5 months ago
16});
17
18fetch(url, {
19 method: "POST",
20 headers: headers,

geocodemain.tsx10 matches

@spinningideas•Updated 5 months ago
39 }, [selectedLocation]);
40
41 const fetchSuggestions = async (input) => {
42 if (suggestionCache.current[input]) {
43 setSuggestions(suggestionCache.current[input]);
47 setIsLoading(true);
48 try {
49 const response = await fetch("/geocode", {
50 method: "POST",
51 headers: { "Content-Type": "application/json" },
52 body: JSON.stringify({ query: input }),
53 });
54 if (!response.ok) throw new Error("Failed to fetch suggestions");
55 const data = await response.json();
56 setSuggestions(data);
57 suggestionCache.current[input] = data;
58 } catch (error) {
59 console.error("Error fetching suggestions:", error);
60 setSuggestions([]);
61 } finally {
64 };
65
66 const debouncedFetchSuggestions = useRef(
67 debounce(fetchSuggestions, 300)
68 ).current;
69
70 useEffect(() => {
71 if (query.length > 2) {
72 debouncedFetchSuggestions(query);
73 } else {
74 setSuggestions([]);
128
129 try {
130 const response = await fetch("https://api.cerebras.ai/v1/chat/completions", {
131 method: "POST",
132 headers: {
146
147 if (!response.ok) {
148 throw new Error("Failed to fetch from Cerebras API");
149 }
150
158 } catch (error) {
159 console.error("Error calling Cerebras API:", error);
160 return new Response(JSON.stringify({ error: "Failed to fetch suggestions" }), {
161 status: 500,
162 headers: { "Content-Type": "application/json" },

whoIsHiringmain.tsx12 matches

@spinningideas•Updated 5 months ago
61 }, [state.loading, state.hasMore]);
62
63 const fetchStories = async () => {
64 try {
65 const response = await fetch("/api/stories");
66 if (!response.ok) throw new Error("Failed to fetch dates");
67 const data = await response.json();
68 setStories(data);
70 }
71 catch (err) {
72 console.error("Error fetching stories:", err);
73 }
74 };
75
76 const fetchComments = async (query: string, story: string, page: number) => {
77 try {
78 dispatch({ type: "loading", value: true });
79 const response = await fetch(`/api/comments?query=${encodeURIComponent(query)}&story=${story}&page=${page}`);
80 if (!response.ok) throw new Error("Failed to fetch comments");
81 const data = await response.json();
82 setComments(prevComments => page === 1 ? data.hits : [...prevComments, ...data.hits]);
84 dispatch({ type: "loading", value: false });
85 } catch (err) {
86 console.error("Error fetching comments:", err);
87 dispatch({ type: "loading", value: false });
88 }
99 dispatch({ type: "hasMore", value: true });
100 dispatch({ type: "query", value: newQuery });
101 fetchComments(fullQuery, state.story, 1);
102 };
103
104 useEffect(() => {
105 fetchStories();
106
107 const handleScroll = () => {
122 : "";
123 const fullQuery = `${filtersQuery} ${state.query}`;
124 fetchComments(fullQuery, state.story, state.page);
125 }
126 }
391 tags: `comment, story_${story}`,
392 page: 0,
393 hitsPerPage: 100, // Fetch a moderate number of comments
394 });
395

sqliteExplorerAppmain.tsx1 match

@granin•Updated 5 months ago
21
22 try {
23 const response = await fetch(window.location.href, {
24 method: 'POST',
25 headers: {

sqlitemain.tsx1 match

@granin•Updated 5 months ago
16
17 try {
18 const response = await fetch(window.location.href, {
19 method: 'POST',
20 headers: {

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago