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/image-url.jpg%20%22Optional%20title%22?q=fetch&page=11&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 8301 results for "fetch"(816ms)

proxyFetch82 file matches

@alp•Updated 1 year ago

fetchGHRepoInfo1 file match

@noartem•Updated 1 year ago

fetchCongressTradeReports1 file match

@nari•Updated 1 year ago

fetchAndStore2 file matches

@tal•Updated 1 year ago

fetchCongressTradeReports1 file match

@claytn•Updated 1 year ago

fetchCat1 file match

@cole•Updated 1 year ago

fetchRSS2 file matches

@stevekrouse•Updated 1 year ago

fetchXML2 file matches

@stevekrouse•Updated 1 year ago

proxyFetch92 file matches

@alp•Updated 1 year ago

testFetch1 file match

@ImGqb•Updated 1 year ago

EEPMOnitoringApp.tsx8 matches

@solomonferede•Updated 56 mins ago
42 const handleLogin = async (username, password) => {
43 try {
44 const response = await fetch("/login", {
45 method: "POST",
46 headers: { "Content-Type": "application/json" },
377 }
378
379 if (path === "/fetch-news" && method === "GET") {
380 const newsArticles = await sqlite.execute(`SELECT * FROM ${KEY}_news_articles ORDER BY created_at DESC`);
381 return new Response(JSON.stringify({ articles: newsArticles.rows }), {
384 }
385
386 if (path === "/fetch-media" && method === "GET") {
387 const mediaEntries = await sqlite.execute(`SELECT * FROM ${KEY}_media_monitoring ORDER BY created_at DESC`);
388 return new Response(JSON.stringify({ entries: mediaEntries.rows }), {
476
477 if (result.rowsAffected > 0) {
478 // Fetch the updated article to return it to the client
479 const updatedArticle = await sqlite.execute(`SELECT * FROM ${KEY}_news_articles WHERE id = ?`, [id]);
480
487 // This case should ideally not happen if rowsAffected > 0, but good for robustness
488 return new Response(
489 JSON.stringify({ success: false, message: "Article updated but could not be refetched" }),
490 {
491 status: 500, // Internal Server Error
538
539 if (result.rowsAffected > 0) {
540 // Fetch the updated entry to return it
541 const updatedEntry = await sqlite.execute(`SELECT * FROM ${KEY}_media_monitoring WHERE id = ?`, [id]);
542 return new Response(JSON.stringify({ success: true, entry: updatedEntry.rows[0] }), {
573 const sevenDaysAgoISO = sevenDaysAgo.toISOString(); // e.g., "2023-10-27T10:00:00.000Z"
574
575 // Fetch news article counts per author in the last 7 days
576 const newsCountsResult = await sqlite.execute(
577 `
584 );
585
586 // Fetch media monitoring counts per author in the last 7 days
587 const mediaCountsResult = await sqlite.execute(
588 `

glastonewsindex.ts10 matches

@bensomething•Updated 1 hour ago
1import process from "node:process";
2import { BskyAgent } from "npm:@atproto/api";
3import fetch from "npm:node-fetch";
4import * as cheerio from "npm:cheerio";
5import fs from "node:fs";
31}
32
33async function fetchWithRetry(url, options = {}, retries = 3, delay = 1000) {
34 for (let i = 0; i < retries; i++) {
35 try {
37 const timeoutId = setTimeout(() => controller.abort(), 10000);
38
39 const response = await fetch(url, {
40 ...options,
41 signal: controller.signal,
49
50 if (!response.ok) {
51 throw new Error(`Failed to fetch: ${response.statusText}`);
52 }
53 return response;
54 } catch (error) {
55 if (i < retries - 1) {
56 console.warn(`Fetch attempt ${i + 1} failed. Retrying...`);
57 await new Promise(resolve => setTimeout(resolve, delay));
58 } else {
63}
64
65async function fetchNews() {
66 const url = "https://glastonburyfestivals.co.uk/news/";
67 try {
68 const response = await fetchWithRetry(url);
69 const html = await response.text();
70 const $ = cheerio.load(html);
84 return news;
85 } catch (error) {
86 console.error("Error fetching news:", error);
87 throw error;
88 }
95
96 const postedNewsTitles = loadPostedNews();
97 const newsItems = await fetchNews();
98 console.log(`Fetched ${newsItems.length} news items.`);
99
100 for (const news of newsItems) {