tokencountermain.tsx1 match
34if (modelFamily === "Anthropic" && anthropicApiKey) {
35try {
36const response = await fetch("/api/count-tokens", {
37method: "POST",
38headers: {
dailySlackStandupmain.tsx2 matches
1import { fetch } from "https://esm.town/v/std/fetch";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import process from "node:process";
55const text = `Time for standup!\n${completion.choices[0].message.content}`;
56// const text = `Time for standup!`;
57// const res = await fetch(
58// webhookUrl,
59// {
generateframeImageREADME.md1 match
3### Why
4I'm using this val for my 3-color e-ink display run by a Raspberry Pi Zero W. The Pi runs a cron job that tell's it
5to fetch this url twice a day and render it to the display. Works like a charm.
67Right now I'm not displaying much but I'm going to keep iterating on what type of information I want to display.
generateframeImagemain.tsx4 matches
7`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t_weather=true&temperature_unit=fahrenheit`;
8try {
9const response = await fetch(url);
10if (!response.ok) {
11throw new Error(`Weather API responded with status: ${response.status}`);
15return data.current_weather;
16} catch (error) {
17console.error("Error fetching weather:", error);
18return null;
19}
135</div>
136)
137: <div className="weather-info">Unable to fetch weather data</div>}
138</div>
139</body>
149150try {
151const response = await fetch(url);
152if (!response.ok) {
153throw new Error(`APIFlash responded with status: ${response.status}`);
neighborhoodOrderAppmain.tsx9 matches
1112useEffect(() => {
13fetchProposals();
14const signed = Cookies.get('signedProposals');
15if (signed) {
18}, []);
1920const fetchProposals = async () => {
21const response = await fetch('/proposals');
22const data = await response.json();
23// Sort proposals by creation date (most recent first)
28const handleSubmitProposal = async (e) => {
29e.preventDefault();
30await fetch('/proposals', {
31method: 'POST',
32headers: { 'Content-Type': 'application/json' },
34});
35setNewProposal({ title: '', proposer: '', targetCount: 10 });
36fetchProposals();
37};
3846return;
47}
48const response = await fetch(`/proposals/${id}/sign`, {
49method: 'POST',
50headers: { 'Content-Type': 'application/json' },
58}
59setSignature('');
60fetchProposals();
61};
6263const handleCancelSignature = async (id, name) => {
64const response = await fetch(`/proposals/${id}/cancel`, {
65method: 'POST',
66headers: { 'Content-Type': 'application/json' },
72setSignedProposals(newSignedProposals);
73Cookies.set('signedProposals', JSON.stringify(Array.from(newSignedProposals)));
74fetchProposals();
75}
76};
simpleWikipediaInstantSearchmain.tsx5 matches
159const query = searchInput.value.trim();
160if (query.length > 0) {
161fetchResults(query);
162} else {
163searchResults.style.display = 'none';
166});
167168async function fetchResults(query) {
169try {
170const response = await fetch(\`/search?q=\${encodeURIComponent(query)}\`);
171const results = await response.json();
172displayResults(results);
173} catch (error) {
174console.error('Error fetching results:', error);
175}
176}
200`;
201202export default app.fetch.bind(app);
multilingualchatroommain.tsx21 matches
195useEffect(() => {
196if (roomId) {
197const fetchDefaultUsername = async () => {
198try {
199// First, check if there's a username in localStorage
202setUsername(storedUsername);
203} else {
204// If not, fetch a default username from the server
205const response = await fetch(`/default-username?room=${roomId}`);
206if (response.ok) {
207const defaultUsername = await response.text();
218}
219} catch (error) {
220console.error("Error fetching default username:", error);
221}
222};
223224fetchDefaultUsername();
225}
226}, [roomId]);
230const pollMessages = async () => {
231try {
232const response = await fetch(`/messages?room=${roomId}&language=${language}`);
233if (response.ok) {
234const newMessages = await response.json();
242}
243} catch (error) {
244console.error("Error fetching messages:", error);
245}
246};
247248const fetchUsers = async () => {
249try {
250const response = await fetch(`/users?room=${roomId}`);
251if (response.ok) {
252const userList = await response.json();
254}
255} catch (error) {
256console.error("Error fetching users:", error);
257}
258};
259260const fetchTypingUsers = async () => {
261try {
262const response = await fetch(`/typing-users?room=${roomId}`);
263if (response.ok) {
264const typingUsersList = await response.json();
266}
267} catch (error) {
268console.error("Error fetching typing users:", error);
269}
270};
271272pollMessages();
273fetchUsers();
274fetchTypingUsers();
275const messageIntervalId = setInterval(pollMessages, 2000);
276const userIntervalId = setInterval(fetchUsers, 5000);
277const typingIntervalId = setInterval(fetchTypingUsers, 1000);
278279return () => {
289if (language !== "en") {
290try {
291const translatedMessage = await fetch("/translate-text", {
292method: "POST",
293headers: { "Content-Type": "application/json" },
315if (inputMessage && roomId && username) {
316try {
317const response = await fetch("/send-message", {
318method: "POST",
319headers: { "Content-Type": "application/json" },
346} else {
347try {
348const response = await fetch("/update-user", {
349method: "POST",
350headers: { "Content-Type": "application/json" },
403if (roomId && username) {
404try {
405await fetch("/update-typing", {
406method: "POST",
407headers: { "Content-Type": "application/json" },
cheerfulCyanBarnaclemain.tsx7 matches
1import { fetch } from "https://esm.town/v/std/fetch";
23export const bookReservationOnResy = async ({
145)
146}&password=${encodeURIComponent(params.password)}`;
147const response = await fetch(`${RESY_API_URL}/3/auth/password`, {
148method: "POST",
149body: body,
167}) => {
168const url = `${RESY_API_URL}/3/details`;
169const response = await fetch(url.toString(), {
170method: "POST",
171headers: RESY_DEFAULT_HEADERS,
192searchParams.set("party_size", params.seats.toString());
193searchParams.set("venue_id", params.venueId);
194const response = await fetch(`${url}?${searchParams}`, {
195method: "GET",
196headers: RESY_DEFAULT_HEADERS,
212searchParams.set("url_slug", params.slug);
213searchParams.set("location", params.city);
214const response = await fetch(`${url}?${searchParams}`, {
215method: "GET",
216headers: RESY_DEFAULT_HEADERS,
224authToken: string;
225}) => {
226const response = await fetch(`${RESY_API_URL}/3/book`, {
227method: "POST",
228headers: {
252venueId,
253});
254console.log("Fetched available slots for day", {
255count: slots.length,
256times: slots.map((slot) => `${slot.date.start} -> ${slot.date.end}`),
8586try {
87const response = await fetch("/", {
88method: "POST",
89body: JSON.stringify({ prompt, currentCode: code, errorMessage: shaderErrorMessage }),
dailyDadJokemain.tsx2 matches
1import { email } from "https://esm.town/v/std/email";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
34export async function dailyDadJoke() {
5let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6return email({
7text: punchline,