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=107&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 8565 results for "fetch"(541ms)

ysrmain.tsx10 matches

@ysr_0•Updated 2 weeks ago
13
14 useEffect(() => {
15 fetchJobPostings();
16 fetchChatMessages();
17 }, []);
18
19 const fetchJobPostings = async () => {
20 const response = await fetch("/job-postings");
21 const data = await response.json();
22 setJobPostings(data);
23 };
24
25 const fetchChatMessages = async () => {
26 const response = await fetch("/chat-messages");
27 const data = await response.json();
28 setChatMessages(data);
31 const submitJobPosting = async (e) => {
32 e.preventDefault();
33 await fetch("/job-postings", {
34 method: "POST",
35 headers: { "Content-Type": "application/json" },
38 setNewJobTitle("");
39 setNewJobDescription("");
40 fetchJobPostings();
41 };
42
47 return;
48 }
49 await fetch("/chat-messages", {
50 method: "POST",
51 headers: { "Content-Type": "application/json" },
56 });
57 setNewChatMessage("");
58 fetchChatMessages();
59 };
60

PassphraseAPImain.http.tsx1 match

@wolf•Updated 2 weeks ago
31 .get("/", (c) => c.redirect("/words"));
32
33export default app.fetch;
34

earningReferralAppmain.tsx4 matches

@Love_78•Updated 2 weeks ago
11
12 useEffect(() => {
13 fetchUserData();
14 }, []);
15
16 const fetchUserData = async () => {
17 try {
18 const response = await fetch('/user-data');
19 const data = await response.json();
20 setUser(data.user);
22 setBalance(data.balance);
23 } catch (error) {
24 console.error('Error fetching user data', error);
25 }
26 };

JobPostingmain.tsx10 matches

@MainaW•Updated 2 weeks ago
10 const handleSubmit = async (e) => {
11 e.preventDefault();
12 const response = await fetch("/job", {
13 method: "POST",
14 headers: { "Content-Type": "application/json" },
53 const [jobs, setJobs] = useState([]);
54
55 const fetchJobs = async () => {
56 const response = await fetch("/jobs");
57 const data = await response.json();
58 setJobs(data);
60
61 useEffect(() => {
62 fetchJobs();
63 }, []);
64
127 const [username, setUsername] = useState("");
128
129 const fetchMessages = async () => {
130 const response = await fetch("/messages");
131 const data = await response.json();
132 setMessages(data);
144 if (!username) return;
145
146 const response = await fetch("/chat", {
147 method: "POST",
148 headers: { "Content-Type": "application/json" },
154 if (response.ok) {
155 setNewMessage("");
156 fetchMessages();
157 }
158 };
159
160 useEffect(() => {
161 fetchMessages();
162 const interval = setInterval(fetchMessages, 5000);
163 return () => clearInterval(interval);
164 }, []);

simpleSurfmain.tsx3 matches

@serostar•Updated 2 weeks ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const simpleSurf = (async () => {
4 // fetch these from the surfline page
5 const spotIds = [
6 "5842041f4e65fad6a770883f",
11 ];
12 const spots = spotIds.join(",");
13 const surfForecast = await fetch(
14 `https://services.surfline.com/kbyg/spots/batch?units%5BswellHeight%5D=FT&units%5Btemperature%5D=F&units%5BtideHeight%5D=FT&units%5BwaveHeight%5D=FT&units%5BwindSpeed%5D=KTS&spotIds=${spots}`,
15 ).then((r) => r.json()).then((d) => d.data);

textToAudioPlayerAudioPlayer.ts1 match

@dcm31•Updated 2 weeks ago
117 try {
118 // Try server-side TTS first
119 const response = await fetch('/text-to-speech', {
120 method: 'POST',
121 headers: {

textToAudioPlayerindex.ts1 match

@dcm31•Updated 2 weeks ago
52 * Server handler that processes requests
53 */
54export default app.fetch;

textToAudioPlayertts.ts1 match

@dcm31•Updated 2 weeks ago
35 console.log("🔊 Sending request to Groq Speech API");
36 const start = Date.now();
37 const response = await fetch("https://api.groq.com/openai/v1/audio/speech", {
38 method: "POST",
39 headers: {

FileDumpThingindex.ts2 matches

@wolf•Updated 2 weeks ago
33 });
34
35// HTTP vals expect an exported "fetch handler"
36// This is how you "run the server" in Val Town with Hono
37export default app.fetch;

textToAudioPlayersw.ts4 matches

@dcm31•Updated 2 weeks ago
54 });
55
56 // Fetch event - serve cached content when offline
57 self.addEventListener('fetch', event => {
58 event.respondWith(
59 caches.match(event.request)
65
66 // Clone the request
67 const fetchRequest = event.request.clone();
68
69 // Make network request and cache the response
70 return fetch(fetchRequest).then(response => {
71 // Check if valid response
72 if (!response || response.status !== 200 || response.type !== 'basic') {

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago