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=717&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 9198 results for "fetch"(1353ms)

getContentFromUrlmain.tsx4 matches

@willthereader•Updated 11 months ago
12 }
13 url = "https://r.jina.ai/" + url
14 const response = await fetch(url);
15 if (!response.ok) {
16 throw new Error(`HTTP error! Status: ${response.status}`);
19 return data;
20 } catch (error) {
21 console.error('Error fetching the URL:', error);
22 return 'Error fetching the content.';
23 }
24};
129});
130
131export default app.fetch;
132

valBackupmain.tsx7 matches

@iamseeley•Updated 11 months ago
10const gitHubAPI = new GitHubAPI(GITHUB_TOKEN);
11
12async function fetchVals() {
13 const response = await valTownAPI.getAllVals();
14 return response.data;
16
17async function getExistingFiles() {
18 console.log(`Fetching existing files from repo: ${GITHUB_REPO}, branch: ${GITHUB_BRANCH}`);
19 try {
20 const response = await gitHubAPI.getRepoContent(GITHUB_REPO, "", GITHUB_BRANCH);
22 return response.map(file => file.path);
23 } catch (error) {
24 console.error(`Error fetching repo content: ${error.message}`);
25 throw error;
26 }
48 const shaResponse = await gitHubAPI.getRepoContent(GITHUB_REPO, filePath, GITHUB_BRANCH);
49 const sha = shaResponse.sha;
50 console.log(`Fetched SHA for ${filePath}: ${sha}`);
51 if (!sha) {
52 throw new Error(`Failed to fetch SHA for ${filePath}`);
53 }
54 await gitHubAPI.updateFile(GITHUB_REPO, filePath, fileContent, sha, commitMessage, GITHUB_BRANCH);
72
73async function backupVals() {
74 const vals = await fetchVals();
75 const lastBackupDates = await getLastBackupDates();
76 const allValsDetails = [];
105
106export async function runBackupIfChanged() {
107 const vals = await fetchVals();
108 const lastBackupDates = await getLastBackupDates();
109

GitHubAPImain.tsx10 matches

@iamseeley•Updated 11 months ago
3
4 async getRepoContent(repo: string, path: string, branch: string) {
5 const response = await fetch(`https://api.github.com/repos/${repo}/contents/${path}?ref=${branch}`, {
6 method: 'GET',
7 headers: {
11
12 if (!response.ok) {
13 throw new Error(`Error fetching repo content: ${response.statusText}`);
14 }
15
18
19 async getFileSHA(repo: string, path: string, branch: string) {
20 const response = await fetch(`https://api.github.com/repos/${repo}/contents/${path}?ref=${branch}`, {
21 method: 'GET',
22 headers: {
26
27 if (!response.ok) {
28 throw new Error(`Error fetching file SHA: ${response.statusText}`);
29 }
30
34
35 async updateFile(repo: string, path: string, content: string, sha: string, message: string, branch: string) {
36 const response = await fetch(`https://api.github.com/repos/${repo}/contents/${path}`, {
37 method: 'PUT',
38 headers: {
68
69 try {
70 const response = await fetch(`${url}?ref=${branch}`, {
71 method: 'GET',
72 headers: {
81 }
82 } catch (error) {
83 console.error(`Error fetching file SHA: ${error.message}`);
84 }
85
86 const response = await fetch(url, {
87 method: 'PUT',
88 headers: {
104
105 async getCommitHistory(repo: string, path: string, branch: string) {
106 const response = await fetch(`https://api.github.com/repos/${repo}/commits?path=${path}&sha=${branch}`, {
107 method: 'GET',
108 headers: {
112
113 if (!response.ok) {
114 throw new Error(`Error fetching commit history: ${response.statusText}`);
115 }
116

ValTownAPImain.tsx4 matches

@iamseeley•Updated 11 months ago
3
4 async getUserID() {
5 const response = await fetch('https://api.val.town/v1/me', {
6 method: 'GET',
7 headers: {
12
13 if (!response.ok) {
14 throw new Error(`Error fetching user details: ${response.statusText}`);
15 }
16
21 async getAllVals() {
22 const userId = await this.getUserID();
23 const response = await fetch(`https://api.val.town/v1/users/${userId}/vals`, {
24 method: 'GET',
25 headers: {
30
31 if (!response.ok) {
32 throw new Error(`Error fetching vals: ${response.statusText}`);
33 }
34

dailySlackRoundupmain.tsx2 matches

@thatbeautifuldream•Updated 11 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { getDayName } from "https://esm.town/v/stevekrouse/getDayName?v=2";
3import process from "node:process";
4
5export const dailySlackRoundup = (async () => {
6 const res = await fetch(process.env.BRAINBOT_WEBHOOK_URL, {
7 method: "POST",
8 body: JSON.stringify({

spotifymain.tsx9 matches

@anthonyec•Updated 11 months ago
2import { home, scopesRoute } from "https://esm.town/v/hunty/spotify_helpers";
3import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
4import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
5import { querystring } from "https://esm.town/v/stevekrouse/querystring";
6import { thisWebURL } from "https://esm.town/v/stevekrouse/thisWebURL";
25
26export let spotifyRequestToken = ({ client_id, client_secret, code, redirect_uri }) =>
27 fetchJSON("https://accounts.spotify.com/api/token", {
28 method: "POST",
29 body: querystring({
39
40export let spotifyRefreshToken = async ({ refresh_token, client_id, client_secret }) =>
41 fetch("https://accounts.spotify.com/api/token", {
42 method: "POST",
43 body: new URLSearchParams({
193
194 try {
195 const currentlyPlaying = await fetch("https://api.spotify.com/v1/me/player/currently-playing", {
196 method: "GET",
197 headers: {
209
210 if (!mostRecentTrack) {
211 const recentTracks = await fetch("https://api.spotify.com/v1/me/player/recently-played", {
212 method: "GET",
213 headers: {
222 }
223 catch (e) {
224 return c.json({ error: "Fetch Error" + e });
225 }
226});
234
235 try {
236 const playStateResponse = await fetch("https://api.spotify.com/v1/me/player?market=US", {
237 method: "GET",
238 headers: {
253 }
254 catch (e) {
255 return c.json({ error: "Fetch Error" + e });
256 }
257});
258
259export default app.fetch;

spotifymain.tsx9 matches

@niek•Updated 11 months ago
2import { home, scopesRoute } from "https://esm.town/v/hunty/spotify_helpers";
3import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
4import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
5import { querystring } from "https://esm.town/v/stevekrouse/querystring";
6import { thisWebURL } from "https://esm.town/v/stevekrouse/thisWebURL";
25
26export let spotifyRequestToken = ({ client_id, client_secret, code, redirect_uri }) =>
27 fetchJSON("https://accounts.spotify.com/api/token", {
28 method: "POST",
29 body: querystring({
39
40export let spotifyRefreshToken = async ({ refresh_token, client_id, client_secret }) =>
41 fetch("https://accounts.spotify.com/api/token", {
42 method: "POST",
43 body: new URLSearchParams({
193
194 try {
195 const currentlyPlaying = await fetch("https://api.spotify.com/v1/me/player/currently-playing", {
196 method: "GET",
197 headers: {
209
210 if (!mostRecentTrack) {
211 const recentTracks = await fetch("https://api.spotify.com/v1/me/player/recently-played", {
212 method: "GET",
213 headers: {
222 }
223 catch (e) {
224 return c.json({ error: "Fetch Error" + e });
225 }
226});
234
235 try {
236 const playStateResponse = await fetch("https://api.spotify.com/v1/me/player?market=US", {
237 method: "GET",
238 headers: {
253 }
254 catch (e) {
255 return c.json({ error: "Fetch Error" + e });
256 }
257});
258
259export default app.fetch;

translatemain.tsx3 matches

@yawnxyz•Updated 11 months ago
3export async function translate(req: Request) {
4 if (req.method === "POST") {
5 return await fetch("https://deepl.deno.dev/translate", {
6 method: "POST",
7 body: await req.text(),
34 <script type="module">
35 import { html, Component, render } from "https://cdn.cbd.int/htm/preact/standalone.module.js";
36 import { ofetch } from "https://esm.sh/ofetch/dist/index.mjs";
37 import { z } from "https://esm.sh/zod";
38 // https://github.com/developit/htm
131 target_lang: z.string().default("zh"),
132 });
133 const data = await ofetch("/", {
134 method: "POST",
135 body: Options.parse({

honoAlpineHtmxDemomain.tsx1 match

@yawnxyz•Updated 11 months ago
66});
67
68export default app.fetch;

honoAlpineExamplemain.tsx1 match

@yawnxyz•Updated 11 months ago
64});
65
66export default app.fetch;

proxyFetch2 file matches

@vidar•Updated 1 day ago

TAC_FetchBasic2 file matches

@A7_OMC•Updated 1 day ago