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=779&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 8124 results for "fetch"(2011ms)

getStatusCodemain.tsx2 matches

@louis•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const getStatusCode = async (url: string, options?: any) => {
4 let f = await fetch(url, { redirect: "follow", ...(options || {}) });
5 return f.text;
6};

chatmain.tsx1 match

@darrinm•Updated 1 year ago
22 document.getElementById("message-input").value = '';
23 const ul = document.getElementById("inbox");
24 const data = await fetch("https://api.val.town/v1/eval/@darrinm.sendChatMessage('" + message + "','"+ sender + "')")
25 .then(res => res.json())
26 .then(res => res.data)

kpunkShowsmain.tsx2 matches

@aeaton•Updated 1 year ago
1import { fetchHtmlDom } from "https://esm.town/v/aeaton/fetchHtmlDom";
2
3export async function kpunkShows() {
4 const url = "https://kpunk.libsyn.com/";
5 const dom = await fetchHtmlDom(url);
6 const items = dom.querySelectorAll(".leftnav a[href^='/webpage']");
7 const regex = /^\/webpage\/\d{4}\/\d{2}$/;

searchClosestWikimain.tsx5 matches

@fab1an•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const searchClosestWiki = async (searchQuery) => {
14 searchQuery
15 )}&srwhat=text&format=json&utf8=1&origin=*`;
16 const searchResponse = await fetch(searchUrl);
17 const searchData = await searchResponse.json();
18 if (!searchData.query.search.length) {
23 pageTitle
24 )}&format=json&utf8=1&origin=*`;
25 const contentResponse = await fetch(contentUrl);
26 const contentData = await contentResponse.json();
27 const pageId = Object.keys(contentData.query.pages)[0];
32 return `${extractedText.trim()}`;
33 } catch (error) {
34 console.log("Error fetching Wikipedia content:", error);
35 return `An error occurred while fetching the Wikipedia content. ${error}`;
36 }
37};

githubStarsmain.tsx2 matches

@joshmock•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function githubStars(username) {
4 let res = await fetch(`https://api.github.com/users/${username}/starred`);
5 return await res.json();
6}

discordSendDMmain.tsx3 matches

@vtdocs•Updated 1 year ago
1import { discordFetch } from "https://esm.town/v/vtdocs/discordFetch";
2
3export const discordSendDM = async (
8 // First, we need a reference to a DM (we create, or get an existing DM)
9 // https://discord.com/developers/docs/resources/user#create-dm
10 const DM = await discordFetch(
11 botToken,
12 "/users/@me/channels",
17 );
18 // Then, we send a message via the DM
19 await discordFetch(
20 botToken,
21 `/channels/${DM.id}/messages`,

telegramSendPhotomain.tsx2 matches

@vtdocs•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export const telegramSendPhoto = async (botToken: string, options: {
15 reply_markup?: any[];
16}) =>
17 fetchJSON(
18 `https://api.telegram.org/bot${botToken}/sendPhoto`,
19 {

bitlyAPImain.tsx2 matches

@galligan•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export let bitlyAPI = ({ token, endpoint, ...params }) => {
5 params.body = JSON.stringify(params.body);
6 }
7 return fetchJSON(
8 `https://api-ssl.bitly.com/v4/${endpoint}`,
9 {

sunbeamValTownFnmain.tsx5 matches

@pomdtr•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export function sunbeamValTownFn(valtownToken: string) {
7 // extension manifest
8 app.get("/", async (c) => {
9 const resp = await fetch("https://api.val.town/v1/me", {
10 headers: {
11 Authorization: `Bearer ${valtownToken}`,
54 }`
55 : `https://api.val.town/v1/users/${user}/vals`;
56 const resp = await fetch(endpoint, {
57 headers: {
58 Authorization: `Bearer ${valtownToken}`,
96 app.post("/view-val", async (c) => {
97 const { params } = await c.req.json();
98 const resp = await fetch(`https://api.val.town/v1/vals/${params.val}`, {
99 headers: {
100 Authorization: `Bearer ${valtownToken}`,
120 });
121 });
122 return app.fetch(req);
123 };
124}

checkRyanairmain.tsx3 matches

@SlugeR•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const checkRyanair = (async () => {
22 const END_TO = "2023-09-30";
23 const PRICE_LIMIT = "260";
24 const fetchUrl = `${BASE_URL}roundTripFares?` +
25 `&arrivalAirportIataCode=${AIRPORT_TO}` +
26 `&departureAirportIataCode=${AIRPORT_FROM}` +
30 `&inboundDepartureDateTo=${END_TO}` +
31 `&priceValueTo=${PRICE_LIMIT}`;
32 const res = await fetch(fetchUrl);
33 const flights = await res.json();
34 console.log(flights?.total);

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago