464465async function makeApiRequest(text) {
466console.log(`Preparing to send fetch request for text: "${text}"`);
467try {
468const response = await fetch(API_CONFIG.url, {
469...API_CONFIG,
470body: JSON.stringify({ selection: text }),
478} catch (error) {
479console.error("Error making API request:", error);
480throw new Error("Failed to fetch definition from the server. Please try again.");
481}
482}
caniuse_notifiermain.tsx3 matches
3233const url = "https://raw.githubusercontent.com/Fyrd/caniuse/main/fulldata-json/data-1.0.json";
34const data = await fetch(url).then((res) => res.json());
35const updatedAt = data.updated;
3637if (previousDataUpdatedAt >= updatedAt) return;
3839const fetchedFeatures = Object.keys(data.data);
4041const features = [];
42for (const feature of fetchedFeatures) {
43const previousFeature = previousData?.[feature];
44const previousUsage = previousFeature?.usage_perc_y ?? 0;
clickTrackerWebsitemain.tsx5 matches
1112useEffect(() => {
13fetchClicks();
14}, []);
1516const fetchClicks = async () => {
17const response = await fetch('/clicks');
18const data = await response.json();
19setClicks(data.clicks);
27origin: { x: clientX / window.innerWidth, y: clientY / window.innerHeight }
28});
29await fetch('/increment', { method: 'POST' });
30fetchClicks();
31};
32
bedtimeStoryMakermain.tsx1 match
518);
519520export default app.fetch;
dateme_migratedmain.tsx2 matches
1import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
2import { form } from "https://esm.town/v/stevekrouse/date_me_form";
3import browse from "https://esm.town/v/stevekrouse/dateme_browse";
13app.get("/faq", faq);
14app.get("/rss.xml", c => dateMeRSS(c.req as unknown as Request));
15export default modifyFetchHandler(app.fetch, {
16style: `@media (max-width: 500px) {
17.github-fork-ribbon {
hnCloneLuciaOauthmain.tsx15 matches
1617useEffect(() => {
18fetchStories();
19fetchUser();
20}, []);
2122const fetchStories = async () => {
23const response = await fetch('/stories');
24const data = await response.json();
25setStories(data);
26};
2728const fetchUser = async () => {
29const response = await fetch('/user');
30const data = await response.json();
31setUser(data.username);
32};
3334const fetchComments = async (storyId) => {
35const response = await fetch(`/comments/${storyId}`);
36const data = await response.json();
37setComments(data);
42const title = event.target.title.value;
43const url = event.target.url.value;
44await fetch('/submit', {
45method: 'POST',
46headers: { 'Content-Type': 'application/json' },
47body: JSON.stringify({ title, url }),
48});
49fetchStories();
50event.target.reset();
51};
53const upvoteStory = async (storyId) => {
54if (!user) return;
55await fetch('/upvote', {
56method: 'POST',
57headers: { 'Content-Type': 'application/json' },
58body: JSON.stringify({ storyId }),
59});
60fetchStories();
61};
6264event.preventDefault();
65const content = event.target.content.value;
66await fetch('/comment', {
67method: 'POST',
68headers: { 'Content-Type': 'application/json' },
69body: JSON.stringify({ storyId: currentStory.id, content, parentId }),
70});
71fetchComments(currentStory.id);
72event.target.reset();
73};
139<span className="story-link" onClick={() => {
140setCurrentStory(story);
141fetchComments(story.id);
142}}>{story.timestamp}</span>
143</div>
muddyAmethystLimpetmain.tsx1 match
2728try {
29const response = await fetch('/upload', {
30method: 'POST',
31body: formData,
2425try {
26const response = await fetch('/upload', {
27method: 'POST',
28body: formData,
pdfExtractTextmain.tsx1 match
3export default async function pdfExtractText(data: ArrayBuffer) {
4const pdfExtract = new PDFExtract();
5// const req = await fetch("https://morth.nic.in/sites/default/files/dd12-13_0.pdf");
6// const data = await req.arrayBuffer();
7const options: PDFExtractOptions = {}; /* see below */
hackerNewsDigestmain.tsx8 matches
3import { email } from "https://esm.town/v/std/email";
45async function fetchStories(type: string, count: number) {
6const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7const storyIds = await response.json();
8const stories = await Promise.all(
9storyIds.slice(0, count).map(async (id: number) => {
10const storyResponse = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);
11return storyResponse.json();
12}),
120export default async function server(req: Request) {
121try {
122const topStories = await fetchStories("top", 10);
123const newStories = await fetchStories("new", 5);
124const showStories = await fetchStories("show", 3);
125const askStories = await fetchStories("ask", 3);
126const jobStories = await fetchStories("job", 3);
127128const emailContent = createEmailContent(topStories, newStories, showStories, askStories, jobStories);