1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let replitGet = (REPLIT_DB_URL, key) => fetch(`${REPLIT_DB_URL}/${key}`);
1import { fetch } from "https://esm.town/v/std/fetch";
2
3let { failureCount } = await import("https://esm.town/v/pranjaldotdev/failureCount");
20 const token =
21 "eyJhbGciOiJIUzI1NiJ9.eyJwbGF0Zm9ybSI6Imppb3Zvb3QiLCJ1c2VyaWR0eXBlIjoidXVpZCIsImlzSmlvVXNlciI6ZmFsc2UsImlzR3Vlc3QiOmZhbHNlLCJwaG9uZU5vIjoiMzM2NjBiNzQtM2U5YS00ZWJhLTlmMTMtNzBkNTQ3NmUwOTNkIiwicHJvZmlsZUlkIjoiMTE1ODc3YWQtZDE3Mi00YTAwLWI2OTMtMDlkZmNjNTEwOTMyIiwiaWF0IjoxNjg5NzA0MzA0LCJleHAiOjE2ODk3OTA3MDR9.ICKpSLJJexKR0wjDYDMpctvdTV33P0J6pxL3MAxWJyg";
22 const response = await fetch(votingURL, {
23 method: "POST",
24 headers: {
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function getWeather(city: string) {
4 try {
5 const response = await fetch(`https://wttr.in/${city}?format=j1`);
6 if (!response.ok) {
7 throw new Error(`Failed to fetch data for ${city}`);
8 }
9 const jsonData = await response.json();
14 }
15 catch (error) {
16 throw new Error(`Failed to fetch weather data: ${error}`);
17 }
18}
1import { fetch } from "https://esm.town/v/std/fetch";
2import { big_stories_ranks } from "https://esm.town/v/tmcw/big_stories_ranks";
3import process from "node:process";
5export let big_story = (async () => {
6 const nytimes =
7 await (await fetch(
8 `https://api.nytimes.com/svc/topstories/v2/home.json?api-key=${process.env.nytimes_api_key}`,
9 )).json();
5 const apiClient = createApiClient("https://api.val.town");
6 const params = {
7 params: { username: "stevekrouse", val_name: "fetchJSON" },
8 };
9 const user = await apiClient.getValname(params);
1import process from "node:process";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function testMutateSemantics({
17 authenticated: boolean;
18}) {
19 const { data: last } = await fetchJSON(
20 `${api}/eval/${stateName}`
21 );
22 const now = Date.now();
23 await fetchJSON(
24 `${api}/eval/${mutator(now)}`,
25 authenticated
29 : undefined
30 );
31 const { data: next } = await fetchJSON(
32 `${api}/eval/${stateName}`
33 );
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2import { openaiOpenAPI } from "https://esm.town/v/stevekrouse/openaiOpenAPI";
3
13Vals are JavaScript & TypeScript code.
14They run server-side on Deno.
15\`fetch\` is in the environment to access any PUBLIC real-time APIs or data feeds.
16Answer any questions about times after your cut off date by querying PUBLIC APIs.
17Do NOT use any API that requires a secret key.
18Only use PUBLIC APIs.
19Do NOT use \`YOUR_API_KEY\`.
20Do NOT import axios or node-fetch. Instead use \`fetch\`.
21Do NOT use newlines. Just use semicolons.
22You can import libraries from npm: \`const {default: _} = await import("npm:lodash")\`
44 try {
45 console.log(req.body);
46 let result = await fetchJSON(
47 "https://api.val.town/v1/eval",
48 { method: "POST", body: JSON.stringify(req.body) },
1import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
2
3export let lookupTwitterIdFree = async (id) =>
4 fetchText("https://tweeterid.com/ajax.php", {
5 "headers": {
6 "accept": "*/*",
11 "sec-ch-ua-mobile": "?0",
12 "sec-ch-ua-platform": '"macOS"',
13 "sec-fetch-dest": "empty",
14 "sec-fetch-mode": "cors",
15 "sec-fetch-site": "same-origin",
16 },
17 "referrer": "https://tweeterid.com/",
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export function openaiFineTune({ key, model, trainingFile }: {
6 trainingFile: string;
7}) {
8 return fetchJSON(
9 "https://api.openai.com/v1/fine_tuning/jobs",
10 {
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export function resend({ from, to, subject, html, text, apiKey }: {
9 apiKey: string;
10}) {
11 return fetchJSON("https://api.resend.com/emails", {
12 method: "POST",
13 headers: {