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/$%7Burl%7D?q=fetch&page=1036&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 13464 results for "fetch"(6919ms)

countGithubLOCUIREADME.md1 match

@g•Updated 7 months ago
9## What It Does
10
11This simple tool fetches the GitHub repository as a ZIP file,
12decompresses it on the fly (thanks to `fflate` 💨),
13and counts the lines of code — on val.town

countGithubLOCmain.tsx1 match

@g•Updated 7 months ago
5 const repo = `${username}/${repoName}`;
6 const url = `https://github.com/${repo}/archive/refs/heads/master.zip`;
7 fetch(url)
8 .then((res) => {
9 if (!res.ok || !res.body) return reject(new Error(`HTTP error! status: ${res.status}`));

multilingualchatroommain.tsx21 matches

@ireneg•Updated 7 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 7 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}`),

countGithubLOCStreamingConceptmain.tsx1 match

@g•Updated 7 months ago
3const repo = 'val-town/sdk';
4const url = `https://github.com/${repo}/archive/refs/heads/master.zip`;
5const res = await fetch(url);
6
7const unzip = new Unzip(onfile);

generateframeImageREADME.md1 match

@michaelwschultz•Updated 7 months ago
5### Why
6I'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
7to fetch this url twice a day and render it to the display. Works like a charm.
8
9Right now I'm not displaying much but I'm going to keep iterating on what type of information I want to display.

multilingualchatroommain.tsx21 matches

@trob•Updated 7 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" },

Update_Wise_Old_ManREADME.md1 match

@evanrh•Updated 7 months ago
6## Config
7
8You need an environment variable called `OSRS_USERS`, which has a comma-separated string of usernames to fetch
9
10Example: `OSRS_USERS=zezima,LynxTitan,Mageboy20`

welcomingPinkAlligatormain.tsx1 match

@problem•Updated 7 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 7 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,

GithubPRFetcher

@andybak•Updated 2 days ago

proxiedfetch1 file match

@jayden•Updated 3 days ago