1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let valTownApiExampleSearch = (async () => {
4 const query = new URLSearchParams({ query: "lodash", limit: "4" });
5 const response = await fetch(`https://api.val.town/v1/search/vals?${query}`);
6 const json = await response.json();
7 return json;
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let blocks_inner = async (req, res) => {
4 const [_, user, id, ...file] = req.path.split("/");
5 const gist = await fetch(`https://api.github.com/gists/${id}`).then((r) =>
6 r.json()
7 );
11 res.set("Content-Type", "application/javascript");
12 return res.send(
13 await fetch(gist.files[file.filter(Boolean).join("/")].raw_url).then(
14 (r) => r.text()
15 ),
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let vid = async (name) =>
4 (await fetchJSON(
5 `https://api.val.town/v1/alias/${name.replace(".", "/").replace("@", "")}`,
6 )).id;
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3// Returns NASA's Astronomy Picture of the Day (APOD)
4export const nasaAPOD = fetchJSON("cutt.ly/T7ksirK");
5// Forked from @iBrokeit.nasaAPOD
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
2
3export async function valTownBlogJSON(): Promise<Blog[]> {
4 let { parse } = await import("npm:node-html-parser");
5 const text = await fetchText("https://blog.val.town");
6 return [
7 ...parse(text)
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Github profile
4export let githubUser = fetchJSON(
5 "https://api.github.com/users/theAJFM"
6);
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function checkPollingStatus() {
15 ];
16 const results = [];
17 const tasResponse = await fetch(tasUrl, {
18 method: "GET",
19 });
24 for (const url of urls) {
25 try {
26 const response = await fetch(url, {
27 method: "GET",
28 });
1export function testFetch(params: any) {
2 return params;
3}
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export const nasaAPOD = fetchJSON("cutt.ly/T7ksirK");
4// Forked from @iBrokeit.nasaAPOD
1import { fetchHtmlDom } from "https://esm.town/v/aeaton/fetchHtmlDom";
2
3export async function peelSessionArtistSessions(url) {
4 const dom = await fetchHtmlDom(url);
5 const list = dom.querySelector(".link-list");
6 const items = list.querySelectorAll("li > a");