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=306&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 3114 results for "fetch"(924ms)

testMutateSemanticsmain.tsx4 matches

@stevekrouse•Updated 1 year ago
1import process from "node:process";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function testMutateSemantics({
17 authenticated: boolean;
18}) {
19 const { data: last } = await fetchJSON(
20 `${api}/eval/${stateName}`
21 );
22 const now = Date.now();
23 await fetchJSON(
24 `${api}/eval/${mutator(now)}`,
25 authenticated
29 : undefined
30 );
31 const { data: next } = await fetchJSON(
32 `${api}/eval/${stateName}`
33 );

chatGPTPluginmain.tsx4 matches

@stevekrouse•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2import { openaiOpenAPI } from "https://esm.town/v/stevekrouse/openaiOpenAPI";
3
13Vals are JavaScript & TypeScript code.
14They run server-side on Deno.
15\`fetch\` is in the environment to access any PUBLIC real-time APIs or data feeds.
16Answer any questions about times after your cut off date by querying PUBLIC APIs.
17Do NOT use any API that requires a secret key.
18Only use PUBLIC APIs.
19Do NOT use \`YOUR_API_KEY\`.
20Do NOT import axios or node-fetch. Instead use \`fetch\`.
21Do NOT use newlines. Just use semicolons.
22You can import libraries from npm: \`const {default: _} = await import("npm:lodash")\`
44 try {
45 console.log(req.body);
46 let result = await fetchJSON(
47 "https://api.val.town/v1/eval",
48 { method: "POST", body: JSON.stringify(req.body) },

lookupTwitterIdFreemain.tsx5 matches

@stevekrouse•Updated 1 year ago
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
2
3export let lookupTwitterIdFree = async (id) =>
4 fetchText("https://tweeterid.com/ajax.php", {
5 "headers": {
6 "accept": "*/*",
11 "sec-ch-ua-mobile": "?0",
12 "sec-ch-ua-platform": '"macOS"',
13 "sec-fetch-dest": "empty",
14 "sec-fetch-mode": "cors",
15 "sec-fetch-site": "same-origin",
16 },
17 "referrer": "https://tweeterid.com/",

openaiFineTunemain.tsx2 matches

@stevekrouse•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export function openaiFineTune({ key, model, trainingFile }: {
6 trainingFile: string;
7}) {
8 return fetchJSON(
9 "https://api.openai.com/v1/fine_tuning/jobs",
10 {

resendmain.tsx2 matches

@stevekrouse•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export function resend({ from, to, subject, html, text, apiKey }: {
9 apiKey: string;
10}) {
11 return fetchJSON("https://api.resend.com/emails", {
12 method: "POST",
13 headers: {

API_URLREADME.md1 match

@std•Updated 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

@std•Updated 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)

blogRSSREADME.md3 matches

@stevekrouse•Updated 1 year ago
7## Architecture
8
91. Fetch and parse the HTML of https://blog.val.town – @stevekrouse.valTownBlogJSON.
102. Create an RSS string out of that array of blog objects – @stevekrouse.valTownBlogRSS.
113. Expose [an endpoint that returns that RSS](https://stevekrouse-blogRSS.web.val.run), with appropriate content-type and cache headers – this val, @stevekrouse.blogRSS
13## Notes
14
15* This is very inefficient. It refetches and re-parses blog.val.town on every single request, modulo some caching via the headers. It would be much more efficient to cache the results of fetching and parsing the Val Town blog, and then only re-fetch it every 10 minutes or so.
16* Instead of fetching and parsing HTML from super.so, we could get this same data from Notion's API, with a val like @stevekrouse.notionGetDatabase.
17
18Migrated from folder: Archive/blogRSS

reasonPhraseREADME.md3 matches

@tmcw•Updated 1 year ago
11_None of this information is useful. The reason-phrase is barely supported on the web and was always an oddity, but keep reading if you like oddities!_
12
13If you're used to JavaScript’s `fetch()` method to make HTTP requests, you've seen the `reason-phrase` under a different name: `statusText`:
14
15```ts
16(await fetch('https://example.com/')).statusText
17```
18
48```
49
50Unfortunately, this doesn't work! The response that Val Town produces is reorganized and optimized by Cloudflare, which upgrades requests and responses from HTTP 1.1 to HTTP 2. And sadly, HTTP 2 [dropped support for the custom reason-phrase](https://fetch.spec.whatwg.org/#concept-response-status-message).
51
52_RIP the `reason-phrase`._ It was present even in a [1992 draft of the HTTP specification](https://www.w3.org/Protocols/HTTP/Response.html), and was a weird and under-appreciated way to pilfer extra information in a response. Now, thanks to HTTP/2 and the commonplace use of proxies and CDNs like Cloudflare, it's no longer usable. It was fun while it lasted.

duckdbExampleREADME.md1 match

@tmcw•Updated 1 year ago
1# DuckDB
2
3[DuckDB](https://duckdb.org/) works on Val Town, with only one small tweak! We're basically using DuckDB in the same way you'd use it with a browser - using the WASM package with its dependencies fetched from [jsdelivr](https://www.jsdelivr.com/).
4
5The only trick is to create the worker ourselves rather than using `duckdb.createWorker`. DuckDB's built-in createWorker method doesn't specify a worker type, which causes `type` to default to `classic`, and Deno (our runtime) doesn't support classic workers.

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago