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/$%7Bart_info.art.src%7D?q=fetch&page=800&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 8244 results for "fetch"(2892ms)

fetchJSONmain.tsx3 matches

@dverginUpdated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let fetchJSON = async (url: string, options?: any) => {
4 //url must return a JSON in string form
5 //this function parses that string into a javascript object
6 let f = await fetch(url, {
7 ...options,
8 headers: {

fetchBcycleCountsmain.tsx10 matches

@jonboUpdated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const fetchBcycleCounts = (async () => {
4 const tokenResponse = await fetch(
5 "https://boulder.bcycle.com/api/bearertoken/getclient?_=1673303289964",
6 {
8 accept: "*/*",
9 "accept-language": "en-US,en;q=0.9",
10 "sec-fetch-dest": "empty",
11 "sec-fetch-mode": "cors",
12 "sec-fetch-site": "same-origin",
13 "sec-gpc": "1",
14 "x-requested-with": "XMLHttpRequest",
23 );
24 const tokenData = await tokenResponse.json();
25 const dataResponse = await fetch(
26 "https://portal-den.bcycle.com/1/publicApi/kiosks?programId=54&refresh=true&_=1673303289965",
27 {
30 "accept-language": "en-US,en;q=0.9",
31 authorization: tokenData.BearerToken,
32 "sec-fetch-dest": "empty",
33 "sec-fetch-mode": "cors",
34 "sec-fetch-site": "same-site",
35 "sec-gpc": "1",
36 },

weatherDescriptionmain.tsx2 matches

@sdanUpdated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const weatherDescription = async (
4 params: string[],
5): Promise<unknown> => {
6 let data = await fetch(`https://wttr.in/${params["city"]}?format=j1`);
7 let jsonData = await data.json();
8 return `${params["city"]}: ${

githubGistsmain.tsx2 matches

@derrickxyzUpdated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// GitHub gists
4export let githubGists = fetchJSON(
5 "https://api.github.com/users/stevekrouse/gists"
6);

fetchTextWithCachingREADME.md1 match

@iakovosUpdated 1 year ago
1Migrated from folder: RSS/fetchTextWithCaching
1Migrated from folder: Tangle_comment_notification/testFetchCommentsVal

fetchCommentsREADME.md1 match

@willthereaderUpdated 1 year ago
1Migrated from folder: Tangle_comment_notification/fetchComments

communityBoatingFlagREADME.md1 match

@twschillerUpdated 1 year ago
1Fetch the sailing flag color from https://www.community-boating.org/

API_URLREADME.md1 match

@stdUpdated 1 year ago
8import { API_URL } from "https://esm.town/v/std/API_URL";
9
10const response = await fetch(`${API_URL}/v1/me`, {
11 headers: {
12 Authorization: `Bearer ${Deno.env.get("valtown")}`,

fetchREADME.md8 matches

@stdUpdated 1 year ago
1# Proxied fetch - [Docs ↗](https://docs.val.town/std/fetch)
2
3The Javascript [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) is directly available within a Val. However sometimes fetch calls are blocked by the receiving server for using particular IP addresses. Additionally, network blips or unreliable web services may lead to failures if not handled properly.
4
5The Val Town standard library contains an alternative version, [`std/fetch`](https://www.val.town/v/std/fetch), that wraps the JavaScript Fetch API to provide additional functionality. The fetch function from [`std/fetch`](https://www.val.town/v/std/fetch) reroutes requests using a proxy vendor so that requests obtain different IP addresses. It also automatically retries failed requests several times. Note that using [`std/fetch`](https://www.val.town/v/std/fetch) will be significantly slower than directly calling the Javascript Fetch API due to extra network hops.
6
7## Usage
8
9After importing [`std/fetch`](https://www.val.town/v/std/fetch), the fetch method is used with the same signature as the Javascript Fetch API.
10
11```ts title="Example" val
12import { fetch } from "https://esm.town/v/std/fetch";
13
14let result = await fetch("https://api64.ipify.org?format=json");
15let json = await result.json();
16console.log(json.ip);
17```
18
19If you run the above code multiple times, you'll see that it returns different IP addresses, because [`std/fetch`](https://www.val.town/v/std/fetch) uses proxies so that each request is made from a different IP address.
20
21
22[📝 Edit docs](https://github.com/val-town/val-town-docs/edit/main/src/content/docs/std/fetch.md)

fetchPaginatedData2 file matches

@nbbaierUpdated 1 week ago

FetchBasic1 file match

@fredmoonUpdated 1 week ago