You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/image-url.jpg%20%22Image%20title%22?q=fetch&page=10&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 8302 results for "fetch"(779ms)
29const itemsPerPage = 5; // Items per page for detailed reports
3031// Function to fetch the detailed report
32const fetchDetailedReport = async () => {
33setDetailedReport(null); // Clear previous data
34setWeeklySummary(null); // Clear other report data
35try {
36const response = await fetch("/generate-report"); // Assuming this endpoint provides detailed data
37const data = await response.json();
38setDetailedReport(data);
39} catch (error) {
40console.error("Failed to fetch detailed report:", error);
41alert("Failed to fetch detailed report.");
42}
43};
4445// Function to fetch the weekly summary report
46const fetchWeeklySummary = async () => {
47setWeeklySummary(null); // Clear previous data
48setDetailedReport(null); // Clear other report data
49try {
50// This fetches the summary data for the last 7 days for all users
51// Assumes the /generate-weekly-summary endpoint exists on the server
52const response = await fetch("/generate-weekly-summary");
53const data = await response.json(); // Assuming data is an array like [{ author: 'User A', submittedArticles: 10, monitoredMedia: 5 }, ...]
54setWeeklySummary(data);
55} catch (error) {
56console.error("Failed to fetch weekly summary:", error);
57alert("Failed to fetch weekly summary.");
58}
59};
6061// Effect to fetch data when the view changes or component mounts
62useEffect(() => {
63if (currentView === "detailed") {
64fetchDetailedReport();
65} else if (currentView === "summary") {
66fetchWeeklySummary();
67}
68}, [currentView]); // Dependency array ensures this runs when currentView changes
346</>
347)
348: <p>Fetching detailed report...</p>} {/* Loading indicator */}
349</>
350)}
399</>
400)
401: <p>Fetching weekly summary...</p>} {/* Loading indicator */}
402</>
403)}
2import { BskyAgent } from "npm:@atproto/api";
3import * as cheerio from "npm:cheerio";
4import fetch from "npm:node-fetch";
56const agent = new BskyAgent({
13]);
1415async function fetchWithRetry(url, options = {}, retries = 3, delay = 1000) {
16for (let i = 0; i < retries; i++) {
17try {
19const timeoutId = setTimeout(() => controller.abort(), 15000); // 15 seconds timeout
2021const response = await fetch(url, {
22...options,
23signal: controller.signal,
3334if (!response.ok) {
35throw new Error(`Failed to fetch: ${response.statusText}`);
36}
37return response;
38} catch (error) {
39if (i < retries - 1) {
40console.warn(`Fetch attempt ${i + 1} failed. Retrying...`);
41await new Promise(resolve => setTimeout(resolve, delay));
42} else {
47}
4849async function fetchNews() {
50const url = "https://glastonburyfestivals.co.uk/news/";
51try {
52const response = await fetchWithRetry(url);
53const html = await response.text();
54const $ = cheerio.load(html);
65return news;
66} catch (error) {
67console.error("Error fetching news:", error);
68throw error;
69}
70}
7172async function fetchEmbedData(url) {
73try {
74const response = await fetchWithRetry(url);
75const html = await response.text();
76const $ = cheerio.load(html);
84const imageUrl = $("meta[property='og:image']").attr("content");
85if (imageUrl) {
86console.log("Fetching image for URL:", imageUrl);
87const imgResponse = await fetchWithRetry(imageUrl);
88const contentType = imgResponse.headers.get("content-type");
89console.log("Image content type:", contentType);
120};
121} catch (error) {
122console.error("Error fetching embed data:", error);
123return null;
124}
130console.log("Logged in successfully.");
131132const newsItems = await fetchNews();
133console.log(`Fetched ${newsItems.length} news items.`);
134135const latestNews = newsItems.find(news => !postedNewsTitles.has(news.title));
138console.log(`Attempting to post new news: ${latestNews.title}`);
139140const embedData = await fetchEmbedData(latestNews.link);
141if (!embedData) {
142console.error("Failed to fetch embed data. Skipping post.");
143return;
144}