35
36async function getMarket(slug: string) {
37 const res = await fetch(`https://api.manifold.markets/v0/slug/${slug}`);
38
39 if (!res.ok) {
20
21async function getNewThreads() {
22 const resp = await fetch(`https://discord.com/api/guilds/${guild}/threads/active`, {
23 headers: {
24 "Authorization": `Bot ${token}`,
7 const title = `@${author}/${name}`;
8
9 const resp = await fetch(`https://api.val.town/v1/alias/${author}/${name}`, {
10 headers: {
11 Authorization: `Bearer ${Deno.env.get("valtown")}`,
1# RPC
2
3Turn any function into an API! This lets you call a function in Val Town without manually handling a `Request` or `Response` object.
4
5This val can be used as a replacement for the Run API, which implicitly did something similar.
6
7## Create an API from your function:
8
9This is how you can expose a function as an API:
10
111. Create an HTTP handler val
1// title: How does this work ?
2
3import { api } from "https://esm.town/v/pomdtr/api";
4import { article } from "https://esm.town/v/pomdtr/article";
5import { extractMetadata } from "https://esm.town/v/pomdtr/extractMetadata";
62
63async function findMyArticles() {
64 let { data: articles } = await api(`/v1/search/vals?query=${encodeURIComponent("#blog")}`);
65
66 return articles.filter(val => {
9 const data = new FormData()
10 data.append("file", blob)
11 const upload = await fetch('https://api.pinata.cloud/pinning/pinFileToIPFS', {
12 method: 'POST',
13 headers: {
2
3export default async function(ctx: BrowserContext) {
4 const resp = await fetch("https://api.iconify.design/collection?prefix=heroicons");
5 if (!resp.ok) {
6 throw new Error(await resp.text());
13## Authentication
14
15Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
16
17## Todos / Plans
12 return randomItems;
13 };
14 const url = `https://alpha.glif.xyz/api/glifs?id=${id}`;
15 try {
16 const response = await fetch(url);
49 JSON.stringify(
50 await (await fetch(
51 "https://api.val.town/v1/eval/"
52 + encodeURIComponent(req.body.data.options[0].value),
53 {