90});
91
92export default app.fetch;
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3interface UpdateValArgs {
20 };
21
22 return fetchJSON(`https://api.val.town/v1/vals/${valId}`, {
23 headers: {
24 Authorization: `Bearer ${token}`,
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3interface UpdateValArgs {
14 };
15
16 return fetchJSON("https://api.val.town/v1/vals", {
17 headers: {
18 Authorization: `Bearer ${token}`,
1# Fetch Paginated Data
2
3This val exports a function that loops through paginated API responses and returns the combined data as an array. It expects pagination with `next` and there to be a `data` property in the API response. This conforms to the Val Town API, so this function is useful when fetching paginated Val Town API responses for creating custom folders in [pomdtr's vscode extension](https://github.com/pomdtr/valtown-vscode).
4
5Usage:
7```ts
8const id = <vt user id>
9await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
10 headers: { Authorization: `Bearer ${Deno.env.get("valtown")}` },
11});
2
3export default async function(interval: Interval) {
4 const versions = await fetch("https://www.figma.com/api/plugins/1323092380415927575/versions").then(r => r.json());
5 const { install_count, like_count, view_count } = versions.meta.plugin;
6
10
11 {
12 const versions = await fetch("https://www.figma.com/api/plugins/1189962635826293304/versions").then(r => r.json());
13 const { install_count, like_count, view_count } = versions.meta.plugin;
14
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let getDadJoke = () => fetchJSON("https://official-joke-api.appspot.com/random_joke");
4app.get("/", (c) => c.text("Hello world!"));
5app.get("/yeah", (c) => c.text("Routing!"));
6export default app.fetch;
432});
433
434export const oldfashioned = app.fetch;
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export const untitled_orangeImpala = fetchJSON(
4 "https://api.openai.com/v1/usage?date=2023-11-01",
5 {
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const nearestOpenStation = async ({ lon, lat }) => {
12 const {
13 data: { stations: stationInfo },
14 } = await fetch(
15 "https://gbfs.citibikenyc.com/gbfs/en/station_status.json"
16 ).then((r) => r.json());
22 const {
23 data: { stations },
24 } = await fetch(
25 "https://gbfs.citibikenyc.com/gbfs/en/station_information.json"
26 ).then((r) => r.json());