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/?q=fetch&page=584&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 15800 results for "fetch"(6945ms)

playgroundwordpress.ts20 matches

@hessammehr•Updated 1 month ago
81}
82
83// Fetch posts with optional parameters
84export async function getPosts(params: {
85 page?: number;
102
103 const url = `${API_URL}/posts?${queryParams.toString()}`;
104 const response = await fetch(url);
105
106 if (!response.ok) {
107 throw new Error(`Failed to fetch posts: ${response.status} ${response.statusText}`);
108 }
109
111}
112
113// Fetch a single post by slug
114export async function getPostBySlug(slug: string): Promise<Post> {
115 const posts = await getPosts({ slug, embed: true });
122}
123
124// Fetch pages with optional parameters
125export async function getPages(params: {
126 page?: number;
139
140 const url = `${API_URL}/pages?${queryParams.toString()}`;
141 const response = await fetch(url);
142
143 if (!response.ok) {
144 throw new Error(`Failed to fetch pages: ${response.status} ${response.statusText}`);
145 }
146
148}
149
150// Fetch a single page by slug
151export async function getPageBySlug(slug: string): Promise<Page> {
152 const pages = await getPages({ slug, embed: true });
159}
160
161// Fetch categories
162export async function getCategories(): Promise<Category[]> {
163 const url = `${API_URL}/categories?per_page=100`;
164 const response = await fetch(url);
165
166 if (!response.ok) {
167 throw new Error(`Failed to fetch categories: ${response.status} ${response.statusText}`);
168 }
169
171}
172
173// Fetch tags
174export async function getTags(): Promise<Tag[]> {
175 const url = `${API_URL}/tags?per_page=100`;
176 const response = await fetch(url);
177
178 if (!response.ok) {
179 throw new Error(`Failed to fetch tags: ${response.status} ${response.statusText}`);
180 }
181
183}
184
185// Fetch media
186export async function getMedia(id: number): Promise<Media> {
187 const url = `${API_URL}/media/${id}`;
188 const response = await fetch(url);
189
190 if (!response.ok) {
191 throw new Error(`Failed to fetch media: ${response.status} ${response.statusText}`);
192 }
193
195}
196
197// Fetch site info
198export async function getSiteInfo() {
199 const url = 'https://mehr-research.science/wp-json';
200 const response = await fetch(url);
201
202 if (!response.ok) {
203 throw new Error(`Failed to fetch site info: ${response.status} ${response.statusText}`);
204 }
205

playgroundindex.ts1 match

@hessammehr•Updated 1 month ago
48});
49
50export default app.fetch;

playgroundREADME.md2 matches

@hessammehr•Updated 1 month ago
1# Astro Frontend for mehr-research.science
2
3This project is an Astro-based frontend for the WordPress website mehr-research.science. It uses the WordPress REST API to fetch content and display it in a modern, fast interface.
4
5## Project Structure
13## Features
14
15- Fetches posts, pages, and other content from WordPress REST API
16- Fast, static-first rendering with Astro
17- Responsive design

demo-ai-mamain.js1 match

@h0a•Updated 1 month ago
94 content.push({ type: 'text', text: prompt });
95
96 const response = await fetch('https://api.anthropic.com/v1/messages', {
97 method: 'POST',
98 headers: {

umbrellaRemindermain.tsx1 match

@louisjrdev•Updated 1 month ago
1export async function testReminder() {
2 fetch('https://jsonplaceholder.typicode.com/todos/1')
3 .then(response => response.json())
4 .then(json => console.log(json)

umbrellaRemindermain.tsx2 matches

@louisjrdev•Updated 1 month ago
1import { email } from "https://esm.town/v/std/email?v=9";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { nominatimSearch } from "https://esm.town/v/stevekrouse/nominatimSearch";
4import { weatherGovGrid } from "https://esm.town/v/stevekrouse/weatherGovGrid";
14 lon,
15 });
16 let { properties: { periods } } = await fetchJSON(
17 grid.forecastHourly,
18 );

TownieuseUser.tsx4 matches

@kenethcosam•Updated 1 month ago
8 const [error, setError] = useState(null);
9
10 const fetchData = async () => {
11 try {
12 const userEndpoint = new URL(USER_ENDPOINT, window.location.origin);
13
14 const res = await fetch(userEndpoint);
15 const data = await res.json();
16 if (!res.ok) {
33
34 useEffect(() => {
35 fetchData();
36 }, []);
37
38 return { data, loading, error, refetch: fetchData };
39}
40

TownieuseProject.tsx5 matches

@kenethcosam•Updated 1 month ago
9 const [error, setError] = useState(null);
10
11 const fetchData = async () => {
12 try {
13 const projectEndpoint = new URL(PROJECT_ENDPOINT, window.location.origin);
17 if (branchId) filesEndpoint.searchParams.append("branchId", branchId);
18
19 const { project } = await fetch(projectEndpoint).then((res) =>
20 res.json()
21 );
22 const { files } = await fetch(filesEndpoint).then((res) => res.json());
23
24 setData({ project, files });
34 useEffect(() => {
35 if (!projectId) return;
36 fetchData();
37 }, [projectId, branchId]);
38
39 return { data, loading, error, refetch: fetchData };
40}
41

TownieuseProjects.tsx4 matches

@kenethcosam•Updated 1 month ago
8 const [error, setError] = useState(null);
9
10 const fetchData = async () => {
11 try {
12 const res = await fetch(ENDPOINT);
13 const data = await res.json();
14 if (!res.ok) {
32
33 useEffect(() => {
34 fetchData();
35 }, []);
36
37 return { data, loading, error, refetch: fetchData };
38}
39

TownieuseCreateProject.tsx1 match

@kenethcosam•Updated 1 month ago
19 setError(null);
20 try {
21 const res = await fetch(ENDPOINT, {
22 method: "POST",
23 headers: {

manual-fetcher

@miz•Updated 5 days ago

fake-https1 file match

@blazemcworld•Updated 2 weeks ago
simple proxy to fetch http urls using https