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/$%7Bsuccess?q=fetch&page=652&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 9115 results for "fetch"(1843ms)

placeholderImagesmain.tsx1 match

@shawnbasquiat•Updated 8 months ago
97 try {
98 console.log(`Generating image with dimensions: ${width}x${height}`);
99 const imageResponse = await fetch(imageGenerationUrl);
100 console.log(`Response status: ${imageResponse.status}`);
101

SocialMediaDashboardV1main.tsx10 matches

@shawnbasquiat•Updated 8 months ago
1// This approach will create a Tinder-like swiping interface for profiles.
2// We'll use React for the frontend, and Val Town's SQLite for persistence.
3// The server will serve the initial HTML and handle API requests for fetching and updating profiles.
4
5/** @jsxImportSource https://esm.sh/react */
15
16 useEffect(() => {
17 fetchProfiles();
18 addSampleProfiles(); // Add this line
19 }, []);
20
21 const fetchProfiles = async () => {
22 const response = await fetch('/profiles');
23 const data = await response.json();
24 setProfiles(data);
26
27 const addSampleProfiles = async () => {
28 await fetch('/add-sample-profiles', {
29 method: 'POST',
30 });
31 fetchProfiles(); // Fetch profiles again after adding samples
32 };
33
34 const clearDatabase = async () => {
35 await fetch('/clear-database', { method: 'POST' });
36 setProfiles([]);
37 setCurrentIndex(0);
45 const addNewProfile = async (e) => {
46 e.preventDefault();
47 const response = await fetch('/add-profile', {
48 method: 'POST',
49 headers: { 'Content-Type': 'application/json' },
53 setMessage('New profile added');
54 setNewProfile({ username: '', image_url: '', link: '', followers: '' });
55 fetchProfiles();
56 } else {
57 setMessage('Failed to add new profile');
67
68 const profile = profiles[currentIndex];
69 const response = await fetch('/swipe', {
70 method: 'POST',
71 headers: { 'Content-Type': 'application/json' },

fetchTwitterUserInfoBrokenmain.tsx5 matches

@shawnbasquiat•Updated 8 months ago
1// This approach will use web scraping to fetch user information given a Twitter handle.
2// We'll fetch the public Twitter profile page and extract the required information.
3
4import cheerio from "https://esm.sh/cheerio@1.0.0-rc.12";
37
38 try {
39 console.log(`Fetching data for handle: ${handle}`);
40 const response = await fetch(`https://twitter.com/${handle}`);
41
42 if (!response.ok) {
131 <body>
132 <h1>Error</h1>
133 <p>Error fetching Twitter data: ${error.message}</p>
134 <p><a href="${url.pathname}">Try again</a></p>
135 </body>

emailListManagermain.tsx4 matches

@shawnbasquiat•Updated 8 months ago
85 <style>${css}</style>
86 <script>
87 // Example of a JavaScript fetch request for addEmail
88 // fetch('/your-val-url', {
89 // method: 'POST',
90 // body: new FormData(document.querySelector('form[action="add"]'))
91 // }).then(response => response.text()).then(result => console.log(result));
92
93 // Example of a JavaScript fetch request for removeEmail
94 // fetch('/your-val-url', {
95 // method: 'POST',
96 // body: new FormData(document.querySelector('form[action="remove"]'))

longOliveGuppymain.tsx4 matches

@sharanbabu•Updated 8 months ago
12
13 useEffect(() => {
14 fetchMessages();
15 }, []);
16
17 const fetchMessages = async () => {
18 const response = await fetch("/messages");
19 const data = await response.json();
20 setMessages(data);
29 setInput("");
30
31 const response = await fetch("/chat", {
32 method: "POST",
33 headers: { "Content-Type": "application/json" },

iangac_validatormain.tsx1 match

@pfeffunit•Updated 8 months ago
71});
72
73export default app.fetch;

sqlitemain.tsx2 matches

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

genimagemain.tsx7 matches

@motyar•Updated 8 months ago
18 setLoading(true);
19 try {
20 const response = await fetch(`/generate?prompt=${encodeURIComponent(prompt)}`, { method: 'POST' });
21 const data = await response.json();
22 setImageUrl(data.imageUrl);
23 // After generating, fetch the updated list of images
24 fetchImages();
25 } catch (error) {
26 console.error("Error generating image:", error);
33 const [selectedImage, setSelectedImage] = useState<GeneratedImage | null>(null);
34
35 const fetchImages = async () => {
36 try {
37 const response = await fetch('/images');
38 const data = await response.json();
39 setImages(data);
40 } catch (error) {
41 console.error("Error fetching images:", error);
42 }
43 };
44
45 React.useEffect(() => {
46 fetchImages();
47 }, []);
48

stagingdailyschedulemain.tsx2 matches

@keenanzucker•Updated 8 months ago
6
7export default async function(req: Request): Promise<Response> {
8 // ============= Data Fetching =================
9 const today = new Date();
10 const tomorrow = addDays(today, 1);
11 const data = await fetch(
12 `https://api.stage.teamsurfboard.com/api/v1/schedule?start=${today.toISOString()}&end=${tomorrow.toISOString()}`,
13 {

dailyDadJokemain.tsx2 matches

@davidpadbury•Updated 8 months ago
1import { email } from "https://esm.town/v/std/email";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({
7 text: punchline,

proxyFetch2 file matches

@vidar•Updated 10 hours ago

TAC_FetchBasic2 file matches

@A7_OMC•Updated 1 day ago