1import { fetch } from "https://esm.town/v/std/fetch";
2
3export default async function readJavascriptWeeklyRss() {
4 try {
5 const response = await fetch("https://cprss.s3.amazonaws.com/javascriptweekly.com.xml");
6 const xml = await response.text();
7 return xml;
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export default async function(req: Request): Promise<Response> {
7 const location = url.get("location");
8 if (url.has("location") && location) {
9 const weather = await fetchJSON(`https://wttr.in/${location}?format=j1&lang=fr`);
10 if (url.has("all")) {
11 return Response.json(weather);
25 const query = JSON.parse(results!);
26
27 // In a real application, you would use the query to fetch data from the database
28 // For this example, we'll just return the query itself
29 return new Response(JSON.stringify({ query, results: "Sample results would go here" }), {
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
5 Here is an example instantdb query (the examples use an unrelated database):
6
7 Fetch namespace
8 One of the simplest queries you can write is to simply get all entities of a namespace:
9 const query = { goals: {} };
10
11 Fetch multiple namespaces
12 You can fetch multiple namespaces at once:
13 const query = { goals: {}, todos: {} };
14
27 }
28
29 Fetch a specific entity
30 If you want to filter entities, you can use the where keyword. Here we fetch a specific goal:
31 const query = {
32 goals: {
55 }
56
57 Fetch associations
58 We can fetch goals and their related todos:
59
60 const query = {
74 }
75
76 Fetch associations for filtered namespace
77 We can fetch a specific entity in a namespace as well as it's related associations.
78
79 const query = {
12 const start = performance.now();
13 try {
14 const res = await fetch(url);
15 end = performance.now();
16 status = res.status;
23 } catch (e) {
24 end = performance.now();
25 reason = `couldn't fetch: ${e}`;
26 ok = false;
27 console.log(`Website down (${url}): ${reason} (${end - start}ms)`);
1async function getInstantSchema(instantAppId: string, instantAdminToken: string) {
2 const response = await fetch("https://api.instantdb.com/admin/schema", {
3 method: "GET",
4 headers: {
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import process from "node:process";
4
5export async function set(key: string, value: any) {
6 let resp = await fetch(
7 `${API_URL}/v1/vals`,
8 {
6 locationURL.searchParams.set("token", IPinfoToken);
7
8 const locationResponse = await fetch(locationURL.href);
9
10 return new Response(locationResponse.body);