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=12&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"(697ms)
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}
3233async function fetchWithRetry(url, options = {}, retries = 3, delay = 1000) {
34for (let i = 0; i < retries; i++) {
35try {
37const timeoutId = setTimeout(() => controller.abort(), 10000);
3839const response = await fetch(url, {
40...options,
41signal: controller.signal,
4950if (!response.ok) {
51throw new Error(`Failed to fetch: ${response.statusText}`);
52}
53return response;
54} catch (error) {
55if (i < retries - 1) {
56console.warn(`Fetch attempt ${i + 1} failed. Retrying...`);
57await new Promise(resolve => setTimeout(resolve, delay));
58} else {
63}
6465async function fetchNews() {
66const url = "https://glastonburyfestivals.co.uk/news/";
67try {
68const response = await fetchWithRetry(url);
69const html = await response.text();
70const $ = cheerio.load(html);
84return news;
85} catch (error) {
86console.error("Error fetching news:", error);
87throw error;
88}
9596const postedNewsTitles = loadPostedNews();
97const newsItems = await fetchNews();
98console.log(`Fetched ${newsItems.length} news items.`);
99100for (const news of newsItems) {
35console.log(`Sending to MCP for ${userIdentifier}:`, JSON.stringify(mcpPayload, null, 2));
3637const mcpApiResponse = await fetch("https://mcp.labspace.ai/chat", {
38method: "POST",
39headers: {
99try {
100console.log(`Attempting to send WhatsApp message to ${userPhoneNumber}`);
101const sendMessageResponse = await fetch(
102`https://graph.facebook.com/v18.0/${business_phone_number_id}/messages`,
103{
135console.log(`Attempting to mark message as read for ${userPhoneNumber} (message_id: ${message.id})`);
136console.log("using API token:", WHATSAPP_GRAPH_API_TOKEN);
137const markReadResponse = await fetch(
138`https://graph.facebook.com/v18.0/${business_phone_number_id}/messages`,
139{
220});
221222// Export app.fetch for Val Town, otherwise export app
223export default (typeof Deno !== "undefined" && Deno.env.get("valtown"))
224? app.fetch
225: app;