Readme

returns the last 100 featured glifs on Glif but with a simplified response shape; I use this in other glifs with the WebFetcher block

use like: https://jamiedubs-glifs.web.val.run/

to fetch info for a single glif, try @jamiedubs/glifJson

#glif #glifs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { fetch } from "https://esm.town/v/std/fetch";
export const glifs = async (id: string) => {
const url = `https://glif.app/api/glifs?featured=1`;
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const json = await response.json();
const data = json.map((glif) => {
return { id: glif.id, name: glif.name, description: glif.description };
});
return Response.json(data);
// return text
// const data = json.map((glif) => {
// return `${glif.id} ${glif.name}`;
// }).join("\n");
// console.log("data", data);
// return new Response(data, { headers: { "Content-Type": "text/plain" }});
}
catch (error) {
return Response.json({ error: error.message });
}
};
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.