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=311&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 4139 results for "fetch"(1191ms)

tokencountermain.tsx1 match

@prashamtrivedi•Updated 5 months ago
34 if (modelFamily === "Anthropic" && anthropicApiKey) {
35 try {
36 const response = await fetch("/api/count-tokens", {
37 method: "POST",
38 headers: {

dailySlackStandupmain.tsx2 matches

@dnishiyama•Updated 5 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import process from "node:process";
55 const text = `Time for standup!\n${completion.choices[0].message.content}`;
56 // const text = `Time for standup!`;
57 // const res = await fetch(
58 // webhookUrl,
59 // {

generateframeImageREADME.md1 match

@stevekrouse•Updated 5 months ago
3### Why
4I'm using this val for my 3-color e-ink display run by a Raspberry Pi Zero W. The Pi runs a cron job that tell's it
5to fetch this url twice a day and render it to the display. Works like a charm.
6
7Right now I'm not displaying much but I'm going to keep iterating on what type of information I want to display.

generateframeImagemain.tsx4 matches

@stevekrouse•Updated 5 months ago
7 `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current_weather=true&temperature_unit=fahrenheit`;
8 try {
9 const response = await fetch(url);
10 if (!response.ok) {
11 throw new Error(`Weather API responded with status: ${response.status}`);
15 return data.current_weather;
16 } catch (error) {
17 console.error("Error fetching weather:", error);
18 return null;
19 }
135 </div>
136 )
137 : <div className="weather-info">Unable to fetch weather data</div>}
138 </div>
139 </body>
149
150 try {
151 const response = await fetch(url);
152 if (!response.ok) {
153 throw new Error(`APIFlash responded with status: ${response.status}`);

neighborhoodOrderAppmain.tsx9 matches

@zlpkhr•Updated 5 months ago
11
12 useEffect(() => {
13 fetchProposals();
14 const signed = Cookies.get('signedProposals');
15 if (signed) {
18 }, []);
19
20 const fetchProposals = async () => {
21 const response = await fetch('/proposals');
22 const data = await response.json();
23 // Sort proposals by creation date (most recent first)
28 const handleSubmitProposal = async (e) => {
29 e.preventDefault();
30 await fetch('/proposals', {
31 method: 'POST',
32 headers: { 'Content-Type': 'application/json' },
34 });
35 setNewProposal({ title: '', proposer: '', targetCount: 10 });
36 fetchProposals();
37 };
38
46 return;
47 }
48 const response = await fetch(`/proposals/${id}/sign`, {
49 method: 'POST',
50 headers: { 'Content-Type': 'application/json' },
58 }
59 setSignature('');
60 fetchProposals();
61 };
62
63 const handleCancelSignature = async (id, name) => {
64 const response = await fetch(`/proposals/${id}/cancel`, {
65 method: 'POST',
66 headers: { 'Content-Type': 'application/json' },
72 setSignedProposals(newSignedProposals);
73 Cookies.set('signedProposals', JSON.stringify(Array.from(newSignedProposals)));
74 fetchProposals();
75 }
76 };

simpleWikipediaInstantSearchmain.tsx5 matches

@maxm•Updated 5 months ago
159 const query = searchInput.value.trim();
160 if (query.length > 0) {
161 fetchResults(query);
162 } else {
163 searchResults.style.display = 'none';
166 });
167
168 async function fetchResults(query) {
169 try {
170 const response = await fetch(\`/search?q=\${encodeURIComponent(query)}\`);
171 const results = await response.json();
172 displayResults(results);
173 } catch (error) {
174 console.error('Error fetching results:', error);
175 }
176 }
200`;
201
202export default app.fetch.bind(app);

multilingualchatroommain.tsx21 matches

@ireneg•Updated 5 months ago
195 useEffect(() => {
196 if (roomId) {
197 const fetchDefaultUsername = async () => {
198 try {
199 // First, check if there's a username in localStorage
202 setUsername(storedUsername);
203 } else {
204 // If not, fetch a default username from the server
205 const response = await fetch(`/default-username?room=${roomId}`);
206 if (response.ok) {
207 const defaultUsername = await response.text();
218 }
219 } catch (error) {
220 console.error("Error fetching default username:", error);
221 }
222 };
223
224 fetchDefaultUsername();
225 }
226 }, [roomId]);
230 const pollMessages = async () => {
231 try {
232 const response = await fetch(`/messages?room=${roomId}&language=${language}`);
233 if (response.ok) {
234 const newMessages = await response.json();
242 }
243 } catch (error) {
244 console.error("Error fetching messages:", error);
245 }
246 };
247
248 const fetchUsers = async () => {
249 try {
250 const response = await fetch(`/users?room=${roomId}`);
251 if (response.ok) {
252 const userList = await response.json();
254 }
255 } catch (error) {
256 console.error("Error fetching users:", error);
257 }
258 };
259
260 const fetchTypingUsers = async () => {
261 try {
262 const response = await fetch(`/typing-users?room=${roomId}`);
263 if (response.ok) {
264 const typingUsersList = await response.json();
266 }
267 } catch (error) {
268 console.error("Error fetching typing users:", error);
269 }
270 };
271
272 pollMessages();
273 fetchUsers();
274 fetchTypingUsers();
275 const messageIntervalId = setInterval(pollMessages, 2000);
276 const userIntervalId = setInterval(fetchUsers, 5000);
277 const typingIntervalId = setInterval(fetchTypingUsers, 1000);
278
279 return () => {
289 if (language !== "en") {
290 try {
291 const translatedMessage = await fetch("/translate-text", {
292 method: "POST",
293 headers: { "Content-Type": "application/json" },
315 if (inputMessage && roomId && username) {
316 try {
317 const response = await fetch("/send-message", {
318 method: "POST",
319 headers: { "Content-Type": "application/json" },
346 } else {
347 try {
348 const response = await fetch("/update-user", {
349 method: "POST",
350 headers: { "Content-Type": "application/json" },
403 if (roomId && username) {
404 try {
405 await fetch("/update-typing", {
406 method: "POST",
407 headers: { "Content-Type": "application/json" },

cheerfulCyanBarnaclemain.tsx7 matches

@ireneg•Updated 5 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const bookReservationOnResy = async ({
145 )
146 }&password=${encodeURIComponent(params.password)}`;
147 const response = await fetch(`${RESY_API_URL}/3/auth/password`, {
148 method: "POST",
149 body: body,
167 }) => {
168 const url = `${RESY_API_URL}/3/details`;
169 const response = await fetch(url.toString(), {
170 method: "POST",
171 headers: RESY_DEFAULT_HEADERS,
192 searchParams.set("party_size", params.seats.toString());
193 searchParams.set("venue_id", params.venueId);
194 const response = await fetch(`${url}?${searchParams}`, {
195 method: "GET",
196 headers: RESY_DEFAULT_HEADERS,
212 searchParams.set("url_slug", params.slug);
213 searchParams.set("location", params.city);
214 const response = await fetch(`${url}?${searchParams}`, {
215 method: "GET",
216 headers: RESY_DEFAULT_HEADERS,
224 authToken: string;
225 }) => {
226 const response = await fetch(`${RESY_API_URL}/3/book`, {
227 method: "POST",
228 headers: {
252 venueId,
253 });
254 console.log("Fetched available slots for day", {
255 count: slots.length,
256 times: slots.map((slot) => `${slot.date.start} -> ${slot.date.end}`),

welcomingPinkAlligatormain.tsx1 match

@problem•Updated 5 months ago
85
86 try {
87 const response = await fetch("/", {
88 method: "POST",
89 body: JSON.stringify({ prompt, currentCode: code, errorMessage: shaderErrorMessage }),

dailyDadJokemain.tsx2 matches

@problem•Updated 5 months ago
1import { email } from "https://esm.town/v/std/email";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({
7 text: punchline,

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago