199
200 try {
201 const response = await fetch("/", {
202 method: "POST",
203 body: JSON.stringify({
8let wordListCache: string[] | null = null;
9if (!wordListCache) {
10 const response = await fetch("https://raw.githubusercontent.com/wordnik/wordlist/main/wordlist-20210729.txt");
11 const text = await response.text();
12 wordListCache = text.trim().split("\n")
187
188 try {
189 const response = await fetch("/", {
190 method: "POST",
191 body: JSON.stringify({
187
188 try {
189 const response = await fetch("/", {
190 method: "POST",
191 body: JSON.stringify({
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let fetchBinance = (payType: string) =>
4 fetch("https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search", {
5 method: "POST",
6 body: JSON.stringify({
1import { email } from "https://esm.town/v/std/email?v=9";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { nominatimSearch } from "https://esm.town/v/stevekrouse/nominatimSearch";
4import { weatherGovGrid } from "https://esm.town/v/stevekrouse/weatherGovGrid";
14 lon,
15 });
16 let { properties: { periods } } = await fetchJSON(
17 grid.forecastHourly,
18 );
124
125 try {
126 const response = await fetch("/login", {
127 method: "POST",
128 headers: { "Content-Type": "application/json" },
135 setUser(data.user);
136 setView("game");
137 fetchLeaderboard();
138 } else {
139 setError(data.message || "Login failed");
144 };
145
146 const fetchLeaderboard = async () => {
147 try {
148 const response = await fetch("/leaderboard");
149 const data = await response.json();
150 setLeaderboard(data.leaderboard);
151 } catch (error) {
152 console.error("Failed to fetch leaderboard:", error);
153 }
154 };
163 try {
164 const token = localStorage.getItem("token");
165 const response = await fetch("/update-score", {
166 method: "POST",
167 headers: {
174 if (data.success) {
175 setUser(prev => ({ ...prev, score: data.newScore, level: data.newLevel }));
176 fetchLeaderboard();
177 }
178 } catch (error) {
247 const token = localStorage.getItem("token");
248 if (token) {
249 fetch("/verify-token", {
250 method: "POST",
251 headers: { "Authorization": `Bearer ${token}` },
256 setUser(data.user);
257 setView("game");
258 fetchLeaderboard();
259 } else {
260 localStorage.removeItem("token");
387
388 try {
389 const response = await fetch('/login', {
390 method: 'POST',
391 headers: { 'Content-Type': 'application/json' },
17 console.log("calling notion api with time:");
18 console.log(eighteenMonthsAgo.toISOString().split("T")[0]);
19 // Fetch pages from Notion database
20 const response = await fetch(`https://api.notion.com/v1/databases/${databaseId}/query`, {
21 method: "POST",
22 headers: {
101 Here is an example instantdb query (the examples use an unrelated database):
102
103 Fetch namespace
104 One of the simplest queries you can write is to simply get all entities of a namespace:
105 const query = { goals: {} };
106
107 Fetch multiple namespaces
108 You can fetch multiple namespaces at once:
109 const query = { goals: {}, todos: {} };
110
123 }
124
125 Fetch a specific entity
126 If you want to filter entities, you can use the where keyword. Here we fetch a specific goal:
127 const query = {
128 goals: {
151 }
152
153 Fetch associations
154 We can fetch goals and their related todos:
155
156 const query = {
170 }
171
172 Fetch associations for filtered namespace
173 We can fetch a specific entity in a namespace as well as it's related associations.
174
175 const query = {
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const sendSMS = async ({
19
20 try {
21 const response = await fetch(`https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Messages.json`, {
22 method: "POST",
23 headers: {