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/$2?q=fetch&page=1040&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 12867 results for "fetch"(6142ms)

mastodonmain.tsx4 matches

@ejfox•Updated 9 months ago
1// This val fetches the 10 most recent Mastodon posts using the Mastodon API.
2// It requires a Mastodon access token stored in the MASTODON_TOKEN environment variable.
3
33 }));
34
35 console.log(`Fetched ${posts.length} Mastodon posts`);
36
37 return Response.json(posts);
38 } catch (error) {
39 console.error("Error fetching Mastodon posts:", error);
40
41 let errorMessage = "An error occurred while fetching Mastodon posts";
42 if (axios.isAxiosError(error)) {
43 if (error.response) {

recentpinboardmain.tsx3 matches

@ejfox•Updated 9 months ago
31 }));
32
33 console.log(`Fetched ${bookmarks.length} bookmarks`);
34
35 return Response.json(bookmarks);
36 } catch (error) {
37 console.error("Error fetching bookmarks:", error);
38
39 let errorMessage = "An error occurred while fetching bookmarks";
40 if (axios.isAxiosError(error)) {
41 if (error.response) {

githubcollabgenmain.tsx4 matches

@ejfox•Updated 9 months ago
8 const user2 = url.searchParams.get("user2") || "stevekrouse";
9
10 async function fetchUserActivity(username: string) {
11 const threeMonthsAgo = new Date(Date.now() - 90 * 24 * 60 * 60 * 1000).toISOString();
12 const response = await fetch(
13 `https://api.github.com/users/${username}/events?per_page=100&since=${threeMonthsAgo}`,
14 );
50 try {
51 const [user1Data, user2Data] = await Promise.all([
52 fetchUserActivity(user1),
53 fetchUserActivity(user2),
54 ]);
55

githubcollabgenREADME.md1 match

@ejfox•Updated 9 months ago
5## Features
6
7- Fetches the last 3 months of GitHub activity for two users
8- Summarizes activity including event counts, repositories, commits, issues, and pull requests
9- Uses AI to generate collaboration suggestions based on the activity summaries

githubactivitysummarizermain.tsx7 matches

@ejfox•Updated 9 months ago
1// This approach fetches GitHub activity for two users specified in the URL,
2// sends it to OpenAI for analysis, and returns collaboration suggestions.
3// It uses the GitHub API (which doesn't require authentication for public data)
4// and the OpenAI API (which does require an API key).
5// Tradeoff: We're using an inline API key for simplicity, which isn't ideal for security.
6// Note: This might hit rate limits for the GitHub API due to fetching a year of data.
7
8import { OpenAI } from "https://esm.town/v/std/openai";
15 const user2 = url.searchParams.get('user2') || 'octocat';
16
17 async function fetchUserActivity(username: string) {
18 const oneYearAgo = new Date(Date.now() - 365 * 24 * 60 * 60 * 1000).toISOString();
19 const response = await fetch(`https://api.github.com/users/${username}/events?per_page=100&since=${oneYearAgo}`);
20 const data = await response.json();
21 if (!Array.isArray(data)) {
27 try {
28 const [user1Data, user2Data] = await Promise.all([
29 fetchUserActivity(user1),
30 fetchUserActivity(user2)
31 ]);
32
39 event.payload.commits.forEach((commit: any) => {
40 if (commit.url) {
41 // This is a simplification. Ideally, we'd fetch each commit to get language info
42 languageSet.add("Unknown");
43 }

githubactivitysummarizerREADME.md1 match

@ejfox•Updated 9 months ago
1# GitHub Activity Summarizer
2
3This val.town script fetches a user's recent GitHub activity and generates a summarized narrative overview using OpenAI's GPT model.
4
5## Features

githubactivitymain.tsx4 matches

@ejfox•Updated 9 months ago
1// This approach uses the GitHub API without authentication, which is subject to rate limiting.
2// We'll fetch and process the GitHub activity data, and render it as a nicely designed website
3// using Vue for templating and Tailwind for styling.
4// Tradeoff: May hit rate limits, but doesn't require setting up a personal access token.
8const GITHUB_USERNAME = "ejfox";
9
10async function fetchGitHubEvents(username: string) {
11 const response = await fetch(`https://api.github.com/users/${username}/events/public`, {
12 headers: {
13 "User-Agent": "Val-Town-Script",
90export default async function main(req: Request): Promise<Response> {
91 try {
92 const events = await fetchGitHubEvents(GITHUB_USERNAME);
93 const recentActivity = processEvents(events);
94

thomasResumeConfigmain.tsx1 match

@iamseeley•Updated 9 months ago
7
8export const resumeConfig = {
9 // URL to fetch the resume JSON data. This should point to your raw resume JSON.
10 // If you want to host your resume JSON somewhere I recommend a setup like this on val town (https://www.val.town/v/iamseeley/resumeDetails) or a github gist.
11 // You can test out the resume view using my resume: https://iamseeley-resumedetails.web.val.run

MiauFoodmain.tsx2 matches

@mauriciobc•Updated 9 months ago
111
112 async function deleteEntry(index) {
113 const response = await fetch('/log', {
114 method: 'DELETE',
115 headers: { 'Content-Type': 'application/json' },
123 async function clearAll() {
124 if (confirm('Are you sure you want to delete all entries?')) {
125 const response = await fetch('/log', { method: 'DELETE' });
126 if (response.ok) {
127 window.location.reload();

sqlitemain.tsx2 matches

@maxm•Updated 9 months ago
35
36async function execute(statement: InStatement): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
39 headers: {
49
50async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
51 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
52 method: "POST",
53 headers: {

fetch-socials4 file matches

@welson•Updated 2 days ago
fetch and archive my social posts

fetchRssForSubcurrent2 file matches

@ashryanio•Updated 2 days ago