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=954&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 14300 results for "fetch"(7184ms)

OpenTelemetryCollectorindex.ts2 matches

@fiberplane•Updated 3 months ago
49 * Export a function that wraps the incoming request,
50 * then injects the Deno env vars into the Hono app befoe
51 * executing the api entrypoint (`app.fetch`)
52 */
53export default async function(req: Request): Promise<Response> {
60 //
61 // If you don't want those values, remove them from the env object
62 return app.fetch(req, env);
63}

ecstaticSalmonOrangutanmain.tsx1 match

@keval•Updated 3 months ago
75
76 try {
77 const response = await fetch("/chat", {
78 method: "POST",
79 headers: { "Content-Type": "application/json" },

loopyLettersmain.tsx5 matches

@alexwein•Updated 3 months ago
81
82 useEffect(() => {
83 fetch("/words")
84 .then(response => response.json())
85 .then(data => {
89 })
90 .catch(error => {
91 console.error("Error fetching words:", error);
92 setWordlist(FALLBACK_WORDLIST);
93 setCurrentWord(FALLBACK_WORDLIST[0]);
260 const resetGame = () => {
261 setIsLoading(true);
262 fetch("/words")
263 .then(response => response.json())
264 .then(data => {
278 })
279 .catch(error => {
280 console.error("Error fetching words:", error);
281 setWordlist(FALLBACK_WORDLIST);
282 setCurrentWordIndex(0);
392 });
393 } catch (error) {
394 console.error("Error fetching words:", error);
395 return new Response(JSON.stringify(FALLBACK_WORDLIST), {
396 headers: { "Content-Type": "application/json" },

blob_adminmain.tsx23 matches

@kaleidawave•Updated 3 months ago
234 const [isDragging, setIsDragging] = useState(false);
235
236 const fetchBlobs = useCallback(async () => {
237 setLoading(true);
238 try {
239 const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
240 const data = await response.json();
241 setBlobs(data);
242 } catch (error) {
243 console.error("Error fetching blobs:", error);
244 } finally {
245 setLoading(false);
248
249 useEffect(() => {
250 fetchBlobs();
251 }, [fetchBlobs]);
252
253 const handleSearch = (e) => {
264 setBlobContentLoading(true);
265 try {
266 const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
267 const content = await response.text();
268 setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
269 setEditContent(content);
270 } catch (error) {
271 console.error("Error fetching blob content:", error);
272 } finally {
273 setBlobContentLoading(false);
278 const handleSave = async () => {
279 try {
280 await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
281 method: "PUT",
282 body: editContent,
290 const handleDelete = async (key) => {
291 try {
292 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
293 setBlobs(blobs.filter(b => b.key !== key));
294 if (selectedBlob && selectedBlob.key === key) {
307 const key = `${searchPrefix}${file.name}`;
308 formData.append("key", encodeKey(key));
309 await fetch("/api/blob", { method: "POST", body: formData });
310 const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
311 setBlobs([newBlob, ...blobs]);
315 }
316 }
317 fetchBlobs();
318 };
319
329 try {
330 const fullKey = `${searchPrefix}${key}`;
331 await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
332 method: "PUT",
333 body: "",
344 const handleDownload = async (key) => {
345 try {
346 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
347 const blob = await response.blob();
348 const url = window.URL.createObjectURL(blob);
363 if (newKey && newKey !== oldKey) {
364 try {
365 const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
366 const content = await response.blob();
367 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
368 method: "PUT",
369 body: content,
370 });
371 await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
372 setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
373 if (selectedBlob && selectedBlob.key === oldKey) {
383 const newKey = `__public/${key}`;
384 try {
385 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
386 const content = await response.blob();
387 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
388 method: "PUT",
389 body: content,
390 });
391 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
392 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
393 if (selectedBlob && selectedBlob.key === key) {
402 const newKey = key.slice(9); // Remove "__public/" prefix
403 try {
404 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
405 const content = await response.blob();
406 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
407 method: "PUT",
408 body: content,
409 });
410 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
411 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
412 if (selectedBlob && selectedBlob.key === key) {
838});
839
840export default lastlogin((request: Request) => app.fetch(request));

reactHonoExampleMessageInput.tsx1 match

@varun1352•Updated 3 months ago
11
12 try {
13 const response = await fetch("/messages", {
14 method: "POST",
15 headers: { "Content-Type": "application/json" },

reactHonoExampleApp.tsx4 matches

@varun1352•Updated 3 months ago
9 const [messages, setMessages] = React.useState(initialMessages);
10
11 const fetchMessages = async () => {
12 try {
13 const response = await fetch("/messages");
14 const data = await response.json();
15 setMessages(data.reverse());
16 } catch (error) {
17 console.error("Failed to fetch messages", error);
18 }
19 };
23 <h1>💬 Message Board</h1>
24 <MessageList messages={messages} />
25 <MessageInput onSubmit={fetchMessages} />
26 {thisProjectURL
27 ? (

unsplashSourceReimplementationmain.tsx5 matches

@charmaine•Updated 3 months ago
154
155 // Serve cached response if less than 1 minute old
156 const imageResponse = await fetch(imageUrl);
157
158 if (imageResponse.ok) {
229
230 try {
231 const response = await fetch(unsplashApiUrl, {
232 headers: {
233 "Accept-Version": "v1",
239 // Include the response body for more detailed error information
240 const errorBody = await response.text();
241 return new Response(`Failed to fetch from Unsplash API: ${errorBody}`, { status: response.status });
242 }
243
247 const imageUrl = `${photo.urls.raw}${additionalParams ? `&${additionalParams}` : ""}`;
248
249 // Fetch the specific image
250 const imageResponse = await fetch(imageUrl);
251
252 if (!imageResponse.ok) {

hnTopStoriesmain.tsx2 matches

@jamiedubs•Updated 3 months ago
25
26async function getTopHNStory() {
27 const topStories = await fetch(
28 "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
29 ).then((res) => res.json());
30
31 const id = topStories[0];
32 const story = await fetch(
33 `https://hacker-news.firebaseio.com/v0/item/${id}.json?print=pretty`
34 ).then((res) => res.json());

resourcefulPurpleBobolinkmain.tsx1 match

@harsha_5870•Updated 3 months ago
11 e.preventDefault();
12 try {
13 const result = await fetch("/process", {
14 method: "POST",
15 body: JSON.stringify({ query })

reactHonoExampleMessageInput.tsx1 match

@sophiehouser•Updated 3 months ago
11
12 try {
13 const response = await fetch("/messages", {
14 method: "POST",
15 headers: { "Content-Type": "application/json" },

FetchBasic2 file matches

@ther•Updated 1 week ago

GithubPRFetcher

@andybak•Updated 1 week ago