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=292&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 3120 results for "fetch"(260ms)

spotifyRefreshTokenmain.tsx2 matches

@stevekrouse•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2import { querystring } from "https://esm.town/v/stevekrouse/querystring";
3
4export let spotifyRefreshToken = async ({ refresh_token, client_id, client_secret }) =>
5 fetchJSON("https://accounts.spotify.com/api/token", {
6 method: "POST",
7 body: await querystring({

getThreadsActivitymain.tsx1 match

@stevekrouse•Updated 1 year ago
20
21async function getNewThreads() {
22 const resp = await fetch(`https://discord.com/api/guilds/${guild}/threads/active`, {
23 headers: {
24 "Authorization": `Bot ${token}`,

auth_middlewaremain.tsx4 matches

@stevekrouse•Updated 1 year ago
46};
47
48async function fetchUser(token: string): Promise<User> {
49 const resp = await fetch("https://api.val.town/v1/me", {
50 headers: {
51 Authorization: `Bearer ${token}`,
54
55 if (resp.status !== 200) {
56 throw new Error("Could not fetch user");
57 }
58
91 const formData = await req.formData();
92 const token = formData.get("token").toString();
93 const user = await fetchUser(token);
94 if (user.username != val.username) {
95 return new Response("Unauthorized", {

fetchPaginatedDataREADME.md3 matches

@nbbaier•Updated 1 year ago
1# Fetch Paginated Data
2
3This val exports a function that loops through paginated API responses and returns the combined data as an array. It expects pagination with `next` and there to be a `data` property in the API response. This conforms to the Val Town API, so this function is useful when fetching paginated Val Town API responses for creating custom folders in [pomdtr's vscode extension](https://github.com/pomdtr/valtown-vscode).
4
5Usage:
7```ts
8const id = <vt user id>
9await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
10 headers: { Authorization: `Bearer ${Deno.env.get("valtown")}` },
11});

placemarkGlobeMonitormain.tsx2 matches

@tmcw•Updated 1 year ago
2
3export default async function(interval: Interval) {
4 const versions = await fetch("https://www.figma.com/api/plugins/1323092380415927575/versions").then(r => r.json());
5 const { install_count, like_count, view_count } = versions.meta.plugin;
6
10
11 {
12 const versions = await fetch("https://www.figma.com/api/plugins/1189962635826293304/versions").then(r => r.json());
13 const { install_count, like_count, view_count } = versions.meta.plugin;
14

untitled_cyanLampreymain.tsx1 match

@stevekrouse•Updated 1 year ago
3import { timed } from "https://esm.town/v/stevekrouse/timed";
4
5const dateme_html_cache = await (await fetch("https://stevekrouse-dateme.web.val.run/")).text();
6
7await blob.delete("dateme_html_cache");

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);

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) {

untitled_pinkRoundwormmain.tsx1 match

@stevekrouse•Updated 1 year ago
22 return c.json({ message: "Comment added!" });
23});
24export default app.fetch;

dailyDadJokemain.tsx2 matches

@stevekrouse•Updated 1 year ago
1import { email } from "https://esm.town/v/std/email";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({
7 text: punchline,

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago