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/$%7Bsuccess?q=fetch&page=664&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 13727 results for "fetch"(1768ms)

stevensDemoApp.tsx17 matches

@niksod•Updated 1 month ago
82 const [cookieAndTeaMode, setCookieAndTeaMode] = useState(false);
83
84 // Fetch images from backend instead of blob storage directly
85 useEffect(() => {
86 // Set default background color in case image doesn't load
89 }
90
91 // Fetch avatar image
92 fetch("/api/images/stevens.jpg")
93 .then((response) => {
94 if (response.ok) return response.blob();
103 });
104
105 // Fetch wood background
106 fetch("/api/images/wood.jpg")
107 .then((response) => {
108 if (response.ok) return response.blob();
129 }, []);
130
131 const fetchMemories = useCallback(async () => {
132 setLoading(true);
133 setError(null);
134 try {
135 const response = await fetch(API_BASE);
136 if (!response.ok) {
137 throw new Error(`HTTP error! status: ${response.status}`);
154 }
155 } catch (e) {
156 console.error("Failed to fetch memories:", e);
157 setError(e.message || "Failed to fetch memories.");
158 } finally {
159 setLoading(false);
162
163 useEffect(() => {
164 fetchMemories();
165 }, [fetchMemories]);
166
167 const handleAddMemory = async (e: React.FormEvent) => {
176
177 try {
178 const response = await fetch(API_BASE, {
179 method: "POST",
180 headers: { "Content-Type": "application/json" },
188 setNewMemoryTags("");
189 setShowAddForm(false);
190 await fetchMemories();
191 } catch (e) {
192 console.error("Failed to add memory:", e);
199
200 try {
201 const response = await fetch(`${API_BASE}/${id}`, {
202 method: "DELETE",
203 });
205 throw new Error(`HTTP error! status: ${response.status}`);
206 }
207 await fetchMemories();
208 } catch (e) {
209 console.error("Failed to delete memory:", e);
231
232 try {
233 const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234 method: "PUT",
235 headers: { "Content-Type": "application/json" },
240 }
241 setEditingMemory(null);
242 await fetchMemories();
243 } catch (e) {
244 console.error("Failed to update memory:", e);

execmain.tsx6 matches

@forafish•Updated 1 month ago
65 const { startDate, endDate } = getYesterdayDateRange();
66
67 const response = await fetch("https://api.linear.app/graphql", {
68 method: "POST",
69 headers: {
80
81 if (data.errors) {
82 console.error("Error fetching data from Linear API:", data.errors);
83 Deno.exit(1);
84 }
86 const issues = data.data.viewer.assignedIssues.nodes;
87
88 // Group issues by team and fetch issue history
89 const issuesByTeam: { [teamName: string]: any[] } = {};
90 for (const issue of issues) {
94 }
95
96 const historyResponse = await fetch("https://api.linear.app/graphql", {
97 method: "POST",
98 headers: {
110 if (historyData.errors) {
111 console.error(
112 `Error fetching history for issue ${issue.id}:`,
113 historyData.errors,
114 );
190 }
191
192 const slackResponse = await fetch("https://slack.com/api/chat.postMessage", {
193 method: "POST",
194 headers: {

cerebras_coderindex.ts1 match

@mirza•Updated 1 month ago
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({

jsonmain.tsx20 matches

@Get•Updated 1 month ago
169
170 // Send the conversation history *before* the user's latest message was added
171 const response = await fetch("/process", {
172 method: "POST",
173 headers: { "Content-Type": "application/json" },
343 try {
344 log("INFO", "Making tool request", { toolName: tool.schema.name, toolId: tool.id });
345 const toolResponse = await fetch("/tool", {
346 method: "POST",
347 headers: { "Content-Type": "application/json" },
351
352 if (controller.signal.aborted) {
353 log("INFO", "Tool request fetch aborted.");
354 // Update the specific tool message to reflect cancellation
355 setMessages(prev =>
1086 }
1087
1088 // fetchData function (handles streaming) - unchanged from previous version
1089 let currentFetchController = null;
1090 async function fetchData(path) {
1091 const cleanPath = '/' + path.replace(/^\\/|\\/$/g, '');
1092 if (cleanPath === '/') {
1094 return;
1095 }
1096 if (currentFetchController) currentFetchController.abort();
1097 currentFetchController = new AbortController();
1098 const signal = currentFetchController.signal;
1099
1100 resultContainer.classList.remove('hidden');
1111
1112 try {
1113 console.log("Fetching:", cleanPath); // Client-side log
1114 const response = await fetch(cleanPath, { signal });
1115 if (!response.ok) {
1116 let errorText = \`Request failed: \${response.status}\`;
1126
1127 while (true) {
1128 if (signal.aborted) { console.log("Fetch aborted."); reader.releaseLock(); return; }
1129 const { done, value } = await reader.read();
1130 if (done) { console.log("Stream finished."); break; }
1172 } catch (error) {
1173 if (error.name !== 'AbortError') {
1174 console.error("Fetch Error:", error); // Client-side log
1175 errorDisplay.textContent = \`Error: \${error.message}\`;
1176 resultData.innerHTML = '<p class="text-red-500 italic">Failed.</p>';
1181 submitButton.disabled = false;
1182 topicInput.disabled = false;
1183 currentFetchController = null;
1184 }
1185 }
1191 e.preventDefault();
1192 const topicPath = topicInput.value.trim();
1193 if (topicPath) { fetchData(topicPath); history.pushState({ path: topicPath }, '', '/' + topicPath.replace(/^\\/|\\/$/g, '')); }
1194 else { errorDisplay.textContent = 'Please enter topic path.'; resultContainer.classList.add('hidden'); }
1195 });
1199 e.preventDefault();
1200 const path = link.getAttribute('href');
1201 if (path) { const pathValue = path.substring(1); topicInput.value = pathValue; fetchData(pathValue); history.pushState({ path: pathValue }, '', path); }
1202 });
1203 }
1206 const pathFromLocation = window.location.pathname.substring(1).replace(/\\/$/, '');
1207 topicInput.value = pathFromLocation;
1208 if (pathFromLocation) { fetchData(pathFromLocation); }
1209 else { resultContainer.classList.add('hidden'); errorDisplay.textContent = ''; topicInput.value = ''; if (currentFetchController) currentFetchController.abort(); }
1210 });
1211 const initialPath = window.location.pathname.substring(1).replace(/\\/$/, '');
1212 if (initialPath && initialPath !== 'favicon.ico') { topicInput.value = initialPath; fetchData(initialPath); }
1213 else { resultContainer.classList.add('hidden'); }
1214 });
1274 + " \"actionType\": \"use_tool\",\n"
1275 + " \"reasoning\": \"Why a tool is needed and what info you need.\",\n"
1276 + " \"response\": \"Inform the user you're fetching data (e.g., 'Let me look that up...').\",\n"
1277 + " \"tool\": {\n"
1278 + " \"id\": null, \n"

buildmoi2a1gpt2 matches

@dcm31•Updated 1 month ago
76 setInput("");
77
78 const response = await fetch("/chat", {
79 method: "POST",
80 headers: { "Content-Type": "application/json" },
93 setInput("");
94
95 const response = await fetch("/generate-image", {
96 method: "POST",
97 headers: { "Content-Type": "application/json" },

stevensDemosendDailyBrief.ts1 match

@zhichu•Updated 1 month ago
135 const lastSunday = today.startOf("week").minus({ days: 1 });
136
137 // Fetch relevant memories using the utility function
138 const memories = await getRelevantMemories();
139

stevensDemoNotebookView.tsx12 matches

@zhichu•Updated 1 month ago
67 const [currentPage, setCurrentPage] = useState(1);
68
69 const fetchMemories = useCallback(async () => {
70 setLoading(true);
71 setError(null);
72 try {
73 const response = await fetch(API_BASE);
74 if (!response.ok) {
75 throw new Error(`HTTP error! status: ${response.status}`);
78 setMemories(data);
79 } catch (e) {
80 console.error("Failed to fetch memories:", e);
81 setError(e.message || "Failed to fetch memories.");
82 } finally {
83 setLoading(false);
86
87 useEffect(() => {
88 fetchMemories();
89 }, [fetchMemories]);
90
91 const handleAddMemory = async (e: React.FormEvent) => {
100
101 try {
102 const response = await fetch(API_BASE, {
103 method: "POST",
104 headers: { "Content-Type": "application/json" },
112 setNewMemoryTags("");
113 setShowAddForm(false);
114 await fetchMemories();
115 } catch (e) {
116 console.error("Failed to add memory:", e);
123
124 try {
125 const response = await fetch(`${API_BASE}/${id}`, {
126 method: "DELETE",
127 });
129 throw new Error(`HTTP error! status: ${response.status}`);
130 }
131 await fetchMemories();
132 } catch (e) {
133 console.error("Failed to delete memory:", e);
155
156 try {
157 const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
158 method: "PUT",
159 headers: { "Content-Type": "application/json" },
164 }
165 setEditingMemory(null);
166 await fetchMemories();
167 } catch (e) {
168 console.error("Failed to update memory:", e);

stevensDemoindex.ts2 matches

@zhichu•Updated 1 month ago
135 ));
136
137// HTTP vals expect an exported "fetch handler"
138export default app.fetch;

stevensDemo.cursorrules5 matches

@zhichu•Updated 1 month ago
163```
164
1655. **fetchTranspiledJavaScript** - Fetch and transpile TypeScript to JavaScript:
166```ts
167const jsCode = await fetchTranspiledJavaScript("https://esm.town/v/username/project/path/to/file.ts");
168```
169
242
243 // Inject data to avoid extra round-trips
244 const initialData = await fetchInitialData();
245 const dataScript = `<script>
246 window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
300
3015. **API Design:**
302 - `fetch` handler is the entry point for HTTP vals
303 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
304 - Properly handle CORS if needed for external access

stevensDemoApp.tsx17 matches

@zhichu•Updated 1 month ago
82 const [cookieAndTeaMode, setCookieAndTeaMode] = useState(false);
83
84 // Fetch images from backend instead of blob storage directly
85 useEffect(() => {
86 // Set default background color in case image doesn't load
89 }
90
91 // Fetch avatar image
92 fetch("/api/images/stevens.jpg")
93 .then((response) => {
94 if (response.ok) return response.blob();
103 });
104
105 // Fetch wood background
106 fetch("/api/images/wood.jpg")
107 .then((response) => {
108 if (response.ok) return response.blob();
129 }, []);
130
131 const fetchMemories = useCallback(async () => {
132 setLoading(true);
133 setError(null);
134 try {
135 const response = await fetch(API_BASE);
136 if (!response.ok) {
137 throw new Error(`HTTP error! status: ${response.status}`);
154 }
155 } catch (e) {
156 console.error("Failed to fetch memories:", e);
157 setError(e.message || "Failed to fetch memories.");
158 } finally {
159 setLoading(false);
162
163 useEffect(() => {
164 fetchMemories();
165 }, [fetchMemories]);
166
167 const handleAddMemory = async (e: React.FormEvent) => {
176
177 try {
178 const response = await fetch(API_BASE, {
179 method: "POST",
180 headers: { "Content-Type": "application/json" },
188 setNewMemoryTags("");
189 setShowAddForm(false);
190 await fetchMemories();
191 } catch (e) {
192 console.error("Failed to add memory:", e);
199
200 try {
201 const response = await fetch(`${API_BASE}/${id}`, {
202 method: "DELETE",
203 });
205 throw new Error(`HTTP error! status: ${response.status}`);
206 }
207 await fetchMemories();
208 } catch (e) {
209 console.error("Failed to delete memory:", e);
231
232 try {
233 const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234 method: "PUT",
235 headers: { "Content-Type": "application/json" },
240 }
241 setEditingMemory(null);
242 await fetchMemories();
243 } catch (e) {
244 console.error("Failed to update memory:", e);

FetchBasic2 file matches

@ther•Updated 2 days ago

GithubPRFetcher

@andybak•Updated 5 days ago