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=467&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 8146 results for "fetch"(1515ms)

GameAwards2024PredictionGamemain.tsx9 matches

@bmitchinson•Updated 4 months ago
12
13 useEffect(() => {
14 fetchData();
15 }, []);
16
17 const fetchData = async () => {
18 try {
19 const response = await fetch("/data");
20 if (!response.ok) {
21 throw new Error("Failed to fetch data");
22 }
23 const { categories, allPredictions } = await response.json();
27 setIsLoading(false);
28 } catch (err) {
29 console.error("Error fetching data:", err);
30 setError(err.message);
31 setIsLoading(false);
183 // Data endpoint
184 if (request.method === "GET" && new URL(request.url).pathname === "/data") {
185 const gistResponse = await fetch(
186 "https://gist.githubusercontent.com/bmitchinson/5c3ed5df80977e402113fc33c149ae7e/raw/ea393f1407d31da96623387299fc6e3702f5fb0a/gameawards_24_backend.json",
187 );
213 const username = segments.pop();
214
215 // Fetch categories
216 const gistResponse = await fetch(
217 "https://gist.githubusercontent.com/bmitchinson/5c3ed5df80977e402113fc33c149ae7e/raw/ea393f1407d31da96623387299fc6e3702f5fb0a/gameawards_24_backend.json",
218 );
219 const categories = await gistResponse.json();
220
221 // Fetch this user's predictions
222 const userResult = await sqlite.execute(
223 `SELECT predictions FROM ${KEY}_predictions_${SCHEMA_VERSION} WHERE username = ?`,

cerebras_codermain.tsx4 matches

@nn6n•Updated 4 months ago
36
37 useEffect(() => {
38 async function fetchStats() {
39 const response = await fetch("/dashboard-stats");
40 const data = await response.json();
41 setStats(data);
42 }
43 fetchStats();
44 }, []);
45
146
147 try {
148 const response = await fetch("/", {
149 method: "POST",
150 body: JSON.stringify({

dedicatedAmethystLeopardmain.tsx5 matches

@mohsen•Updated 4 months ago
14
15 useEffect(() => {
16 fetchStocks();
17 }, []);
18
19 async function fetchStocks() {
20 const response = await fetch('/stocks');
21 const data = await response.json();
22 setStocks(data);
33 async function addStock(e) {
34 e.preventDefault();
35 const response = await fetch('/stocks', {
36 method: 'POST',
37 headers: {
42
43 if (response.ok) {
44 fetchStocks();
45 setNewStock({
46 symbol: '',

blobReadPictureExamplemain.tsx1 match

@adnanwahab•Updated 4 months ago
5 try {
6 // Use a public screenshot service that doesn't require authentication
7 const screenshotResponse = await fetch(`https://api.urlbox.io/v1/render/screenshot?url=${encodeURIComponent(url)}&width=1280&height=720`);
8
9 if (!screenshotResponse.ok) {

cerebras_codermain.tsx4 matches

@mimoinverse•Updated 4 months ago
36
37 useEffect(() => {
38 async function fetchStats() {
39 const response = await fetch("/dashboard-stats");
40 const data = await response.json();
41 setStats(data);
42 }
43 fetchStats();
44 }, []);
45
146
147 try {
148 const response = await fetch("/", {
149 method: "POST",
150 body: JSON.stringify({

currencymain.tsx5 matches

@luizhrios•Updated 4 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3function fetchJSON(url) {
4 return fetch(url).then(res => res.json());
5}
6
7export let currency = async (desired, base = "usd", amount = 1) => {
8 let { rates } = await fetchJSON(`https://open.er-api.com/v6/latest/${base}`);
9 if (false && rates && rates[desired.toUpperCase()]) return amount * (rates[desired.toUpperCase()]);
10 else {
11 let { rates } = await fetchJSON("https://api.coingecko.com/api/v3/exchange_rates");
12 return amount * rates[desired.toLowerCase()]?.value / rates[base.toLowerCase()]?.value;
13 }

productiveRosePeacockmain.tsx4 matches

@stevekrouse•Updated 4 months ago
36
37 useEffect(() => {
38 async function fetchStats() {
39 const response = await fetch("/dashboard-stats");
40 const data = await response.json();
41 setStats(data);
42 }
43 fetchStats();
44 }, []);
45
146
147 try {
148 const response = await fetch("/", {
149 method: "POST",
150 body: JSON.stringify({

prodigiousBrownImpalamain.tsx4 matches

@stevekrouse•Updated 4 months ago
36
37 useEffect(() => {
38 async function fetchStats() {
39 const response = await fetch("/dashboard-stats");
40 const data = await response.json();
41 setStats(data);
42 }
43 fetchStats();
44 }, []);
45
146
147 try {
148 const response = await fetch("/", {
149 method: "POST",
150 body: JSON.stringify({

BestTime2postmain.tsx1 match

@taurusismagic•Updated 4 months ago
60
61 try {
62 const response = await fetch("/check-email", {
63 method: "POST",
64 headers: { "Content-Type": "application/json" },

captivatingPurpleTapirmain.tsx20 matches

@mohsen•Updated 4 months ago
15
16 useEffect(() => {
17 fetchStocks();
18 fetchOperations();
19 }, []);
20
21 async function fetchStocks() {
22 const response = await fetch('/stocks');
23 const data = await response.json();
24 setStocks(data);
25 }
26
27 async function fetchOperations() {
28 const response = await fetch('/operations');
29 const data = await response.json();
30 setOperations(data);
33 async function addStock(e) {
34 e.preventDefault();
35 const response = await fetch('/stocks', {
36 method: 'POST',
37 headers: { 'Content-Type': 'application/json' },
38 body: JSON.stringify(newStock)
39 });
40 await fetchStocks();
41 await fetchOperations();
42 setNewStock({ symbol: '', shares: 0, purchasePrice: 0, sellPrice: 0 });
43 }
44
45 async function deleteStock(symbol: string, shares: number, purchasePrice: number) {
46 const response = await fetch('/stocks', {
47 method: 'DELETE',
48 headers: { 'Content-Type': 'application/json' },
49 body: JSON.stringify({ symbol, shares, purchasePrice })
50 });
51 await fetchStocks();
52 await fetchOperations();
53 }
54
55 async function updateStock(stock) {
56 const response = await fetch('/stocks', {
57 method: 'PUT',
58 headers: { 'Content-Type': 'application/json' },
59 body: JSON.stringify(stock)
60 });
61 await fetchStocks();
62 await fetchOperations();
63 setEditingStock(null);
64 }
178 stock.shares,
179 stock.purchasePrice,
180 await fetchStockPrice(stock.symbol),
181 stock.sellPrice || null
182 ]
269}
270
271// Existing fetchStockPrice function remains the same
272async function fetchStockPrice(symbol: string): Promise<number> {
273 try {
274 const response = await fetch(`https://query1.finance.yahoo.com/v8/finance/chart/${symbol}`);
275 const data = await response.json();
276 return data.chart.result[0].meta.regularMarketPrice;
277 } catch {
278 return 0; // Default to 0 if price can't be fetched
279 }
280}

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago