13```
14
15You can then fetch the exported string from outside val.town using:
16
17```sh
2
3export const handler = async () => {
4 const hashrateResp = await fetch("https://mempool.space/api/v1/mining/hashrate/3y");
5 const { difficulty } = await hashrateResp.json();
6
2
3export default async function(req: Request): Promise<Response> {
4 const blockFeesResp = await fetch("https://mempool.space/api/v1/mining/blocks/fees/3y");
5 const blockFees = await blockFeesResp.json();
6
2
3export const handler = async () => {
4 const resp = await fetch("https://mempool.space/api/v1/mining/hashrate/3y");
5 const { difficulty, hashrates } = await resp.json();
6
52```
53
54Cli vals don't have access to val town tokens. Instead of trying to replicate your valtown secrets locally, you can configure your cli vals to call your http endpoints using `fetch`.
6import {
7 init,
8 traced_fetch,
9 traced_handler,
10} from "https://esm.town/v/saolsen/tracing";
39 val_req_url = `${val_req_url}?v=${version}`;
40 }
41 const val_resp: Response = await traced_fetch(val_req_url);
42 const val_version = Number(val_resp.url.split("?v=")[1]);
43 const val_body: string = await val_resp.text();
166async function handler(req: Request): Promise<Response> {
167 await track("saolsen.changes", req);
168 return await app.fetch(req);
169}
170
1import { email } from "https://esm.town/v/std/email?v=11";
2import { fetchRSS } from "https://esm.town/v/stevekrouse/fetchRSS";
3import { newRSSItems } from "https://esm.town/v/stevekrouse/newRSSItems?v=6";
4import { parseXML } from "https://esm.town/v/stevekrouse/parseXML";
8 const lastRunAt = interval.lastRunAt;
9
10 const response = await fetch("https://sive.rs/en.atom");
11 const xml = await response.text();
12 const data = await parseXML(xml);
2import { email } from "https://esm.town/v/std/email?v=9";
3import { set } from "https://esm.town/v/std/set?v=11";
4import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
5
6export const runner = async () => {
14 ];
15 const promises = ALERT_STRINGS.map(async function(keyword) {
16 let posts = await fetchJSON(
17 `https://search.bsky.social/search/posts?q=${keyword}`,
18 );
1import { ConstructReadTangleUrl } from "https://esm.town/v/willthereader/ConstructReadTangleUrl";
2import { fetchComments } from "https://esm.town/v/willthereader/fetchComments";
3import { logMessage } from "https://esm.town/v/willthereader/logMessage";
4import { testUrlConstructionVal } from "https://esm.town/v/willthereader/testUrlConstructionVal";
5
6export const testFetchCommentsVal = async () => {
7 const urls = [
8 "https://www.readtangle.com/members/api/comments/?post_id=0%3A6",
22 "https://www.readtangle.com/members/api/comments/?post_id=0%3A6",
23 ]; // Await the resolution of the promise from testUrlConstructionVal
24 await fetchComments(urls); // Now urls is an array, so it can be passed to fetchComments
25};
26
27testFetchCommentsVal();
1import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=42";
3
4export default async function (req: Request) {
27 }
28
29 const gist = await fetchJSON(`https://api.github.com/gists/${id}`);
30 if (gist.owner.login != author) {
31 return new Response("Unauthorized", {