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=704&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 8301 results for "fetch"(1615ms)

untitled_indigoNightingalemain.tsx1 match

@stevekrouse•Updated 1 year ago
11app.get("/edit/:blob", async (c) => c.html(`TODO: Edit ${c.req.param("blob")}`));
12app.get("/delete/:blob", async (c) => c.html(`TODO: Delete ${c.req.param("blob")}`));
13export default basicAuth(app.fetch);

HTHTMXmain.tsx1 match

@wilhelm•Updated 1 year ago
70});
71
72export default app.fetch;

basicAuthmain.tsx4 matches

@stevekrouse•Updated 1 year ago
18};
19
20async function fetchUser(token: string): Promise<User> {
21 const resp = await fetch("https://api.val.town/v1/me", {
22 headers: {
23 Authorization: `Bearer ${token}`,
26
27 if (resp.status !== 200) {
28 throw new Error("Could not fetch user");
29 }
30
34async function isTokenValid(token) {
35 try {
36 const [visitor, owner] = await Promise.all([fetchUser(token), fetchUser(Deno.env.get("valtown"))]);
37 return visitor.id == owner.id;
38 } catch (err) {

setSFTidbytImagemain.tsx2 matches

@squarethecircle•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import process from "node:process";
3
8 const apiKey = process.env.sf_tidbyt_api_key;
9 const deviceId = process.env.sf_tidbyt_device_id;
10 const res = await fetch(
11 `https://api.tidbyt.com/v0/devices/${deviceId}/push`,
12 {

untitled_amberBedbugmain.tsx4 matches

@sreenandm•Updated 1 year ago
1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
9}
10
11const randomJoke = await fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;

notemsmain.tsx2 matches

@yieldray•Updated 1 year ago
5export const set = async (key: string, value = "") => {
6 if (!isValidKey(key)) throw new Error(`Invalid note.ms key`);
7 const res = await fetch(`https://note.ms/${key}`, {
8 headers: {
9 "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
18export const get = async (key: string) => {
19 if (!isValidKey(key)) throw new Error(`Invalid note.ms key`);
20 const res = await fetch(`https://note.ms/${key}`, { headers: { Referer: `https://note.ms/${key}` } });
21 if (!res.ok) throw new Error(res.statusText);
22 const matched = (await res.text()).match(/<textarea class="content">([\s\S]*?)<\/textarea>/);

gpt3Examplemain.tsx1 match

@ktodaz•Updated 1 year ago
2
3const gpt3Example = async () => {
4 const response = await fetch("https://api.openai.com/v1/completions", {
5 method: "POST",
6 headers: {

untitled_sapphireSlugmain.tsx1 match

@lolocoo•Updated 1 year ago
13
14 try {
15 const data = await fetch(
16 `https://www.googleapis.com/customsearch/v1?q=${searchKey}&cx=70c6ff0b41f6943a4&key=AIzaSyAY7rS9VJVEcS6196uOWXOx2mCq_cN2kXM&c2coff=1&start=1&num=5&dateRestrict=m%5B1%5D`,
17 )

connect4_agentmain.tsx1 match

@saolsen•Updated 1 year ago
22 }
23 });
24 return app.fetch;
25}

googlesearchmain.tsx2 matches

@lolocoo•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import process from "node:process";
3
25
26 const getSearch = async (data) => {
27 const response = await fetch("https://api.openai.com/v1/completions", {
28 method: "GET",
29 body: JSON.stringify(data),

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago