Val Town Search


U9G/fetchJSON
import { fetch } from "https://esm.town/v/std/fetch";

export let fetchJSON = async (url: string, options?: any) => {
  let f = await fetch(url, {
    ...options,
    headers: {
      "Content-Type": "application/json",
maxm/fetchJSON
import { normalizeURL } from "https://esm.town/v/stevekrouse/normalizeURL";

export const fetchJSON = async (
  url: string | URL,
  options?: RequestInit & {
    bearer?: string;
    fetch?: typeof fetch;
ejfox/todaystats
}

// Utility function for fetching JSON data
async function fetchJSON(url: string) {
  try {
    const response = await fetch(url);
    if (!response.ok) {
avycado13/valboard
import { h } from "https://esm.sh/[email protected]";

// Function to fetch JSON data from URL
async function fetchJSON(url: string) {
  try {
    console.log(`Attempting to fetch data from: ${url}`);
    const response = await fetch(url);
sammeltassen/rijks
  }];
}

async function fetchJson(id: string) {
  const headers = new Headers([
    ["Accept-Profile", "edm"],
    ["Accept", "application/rdf+xml"],
val/fetchJSON
import { fetch } from "https://esm.town/v/std/fetch";
import { normalizeURL } from "https://esm.town/v/stevekrouse/normalizeURL?v=3";

export const fetchJSON = async (url: string, options?: any) => {
  let f = await fetch(normalizeURL(url), {
    redirect: "follow",
    ...options,
stevekrouse/fetchJSON_example
import { fetch } from "https://esm.town/v/std/fetch?v=4";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";

console.log(await fetchJSON("https://pie.dev/get"));
console.log(await fetchJSON("https://pie.dev/get", { fetch }));
bdon/usd_twd_converter
import { email } from "https://esm.town/v/std/email";
import { fetch } from "https://esm.town/v/std/fetch";

function fetchJSON(url) {
  return fetch(url).then(res => res.json());
}
export let currency = async (desired, base = "usd", amount = 1) => {
ychu/aqi
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";

export let aqi = async () => {
  let pm25 = (
    await fetchJSON(
      "https://api.openaq.org/v2/latest?" +
        new URLSearchParams({
axelav/home
import { fetchJSON } from "https://esm.town/v/axelav/fetchJSON";
import process from "node:process";

export async function home(req: express.Request, res: express.Response) {
  interface Artist {
    name: string;
    join: string;
mgruel/alias
import { fetchJSON } from "https://esm.town/v/mgruel/fetchJSON";

type UserParams = {
  username: string;
};
type ValParams = {
  username: string;
sco/bskyPosts
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";

// Use this to get the Bluesky posts from any user.
// Just pass in their username (like "vgr.bsky.social")
export const bskyPosts = async (repo = "scottraymond.com") => {
  const { records } = await fetchJSON(
    `https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=${repo}&collection=app.bsky.feed.post`
pomdtr/runGist
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=42";

export default async function (req: Request) {
  const url = new URL(req.url);
  const [, id, action] = url.pathname.split("/");
  if (!id) {
valbee/imBored
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
let { boredActivities } = await import("https://esm.town/v/valbee/boredActivities");

export const imBored = async () => {
  return (boredActivities = fetchJSON(
    "https://www.boredapi.com/api/activity"
  ));
axelav/discogs
import { fetchJSON } from "https://esm.town/v/axelav/fetchJSON";
import process from "node:process";

export async function discogs(
  request: express.Request,
  response: express.Response
) {
danny/starWars
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";

// Explore the Star Wars universe, from StarWarsAPI
export let starWars = fetchJSON(
  "https://swapi.dev/api/people/1/",
insanity54/mil
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";

export const mil = async () => {
  const json = await fetchJSON(
    "https://www.coingecko.com/nft/milady-maker/chart.json?currency=eth&days=1",
  );
  return json.stats[json.stats.length - 1];
neverstew/getMe
import process from "node:process";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";

export let getMe = fetchJSON(`https://api.val.town/v1/me`, {
  headers: {
    Authorization: `Bearer ${process.env.valtownToken}`,
  },
stevekrouse/uid
import { handle } from "https://esm.town/v/stevekrouse/handle";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";

export let uid =
  (await fetchJSON(
    `https://api.val.town/v1/alias/${handle}`,
nbbaier/valToGH
import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=42";
import { Octokit } from "npm:@octokit/rest";
import { DateTime } from "npm:luxon";

async function getLatestCommit(ghUser: string, ghRepo: string, branch: string, client: Octokit)
{
begoon/slackbot
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";

const { env } = Deno;

const SLACK_BOT_TOKEN = env.get("SLACK_BOT_TOKEN");
const SLACK_SIGNING_SECRET = env.get("SLACK_SIGNING_SECRET");
const SLACK_VERIFICATION_TOKEN = env.get("SLACK_VERIFICATION_TOKEN");
fossforlife/mediumToMarkdown
// Altered from https://github.com/ericclemmons/medium-to-markdown

const fetchJSON = async (url, startAt = 0) => {
  const response = await fetch(url);
  const text = await response.text();
  const json = JSON.parse(text.slice(startAt));
stevekrouse/rime
import process from "node:process";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
import { rimeRateLimitExceeded } from "https://esm.town/v/stevekrouse/rimeRateLimitExceeded";

// We provide some amount of free usage to this API
// Callable with my API key via api(@stevekrosue.rime, {text: "blah blah", ...})
export async function rime({ text, speaker, key }: {
rjeli/holidaysUS
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";

// Public holidays in the US in 2023
export let holidaysUS = fetchJSON(
  "https://date.nager.at/api/v2/publicholidays/2023/US"
csellis/currency
import { fetchJSON } from "https://esm.town/v/radu/fetchJSON?v=3";

export let currency = async (base = "usd", desired?: string = "php") => {
  let { rates } = await fetchJSON(
    `https://open.er-api.com/v6/latest/${base}`,
  );
  return rates;
mihir/forceUnsub
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
import { getGoogleAccessTokenFromRefreshToken } from "https://esm.town/v/mihir/getGoogleAccessTokenFromRefreshToken";

export let forceUnsub = async (emails: string[]) => {
  const { access_token } =
    await getGoogleAccessTokenFromRefreshToken();
roramigator/pr0n
/** @jsxImportSource https://esm.sh/react */
import React, { useEffect, useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";

const subreddits = ["Battletops", "AverageBattlestations", "desksetup"];
rlimit/ratelimit
import { parentReference } from "https://esm.town/v/stevekrouse/parentReference?v=3";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
import { runVal } from "https://esm.town/v/std/runVal";

export let ratelimit = async (limit: string, key?: string = "default", namespaceId?: string, namespacePassword?: string) : Promise<{
  ok: boolean,
  status: number,
stevekrouse/myIP
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";

export const myIP = () =>
  fetchJSON("https://api.ipify.org?format=json");
stevekrouse/runs
import { searchParams } from "https://esm.town/v/stevekrouse/searchParams";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";

export function runs({ token, error, source, since, until, offset, limit }: {
  token: string;
  error?: boolean;
  source?: ("api" | "ui" | "interval" | "email")[];