loopyLettersmain.tsx5 matches
8182useEffect(() => {
83fetch("/words")
84.then(response => response.json())
85.then(data => {
89})
90.catch(error => {
91console.error("Error fetching words:", error);
92setWordlist(FALLBACK_WORDLIST);
93setCurrentWord(FALLBACK_WORDLIST[0]);
260const resetGame = () => {
261setIsLoading(true);
262fetch("/words")
263.then(response => response.json())
264.then(data => {
278})
279.catch(error => {
280console.error("Error fetching words:", error);
281setWordlist(FALLBACK_WORDLIST);
282setCurrentWordIndex(0);
392});
393} catch (error) {
394console.error("Error fetching words:", error);
395return new Response(JSON.stringify(FALLBACK_WORDLIST), {
396headers: { "Content-Type": "application/json" },
blob_adminmain.tsx23 matches
234const [isDragging, setIsDragging] = useState(false);
235236const fetchBlobs = useCallback(async () => {
237setLoading(true);
238try {
239const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
240const data = await response.json();
241setBlobs(data);
242} catch (error) {
243console.error("Error fetching blobs:", error);
244} finally {
245setLoading(false);
248249useEffect(() => {
250fetchBlobs();
251}, [fetchBlobs]);
252253const handleSearch = (e) => {
264setBlobContentLoading(true);
265try {
266const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
267const content = await response.text();
268setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
269setEditContent(content);
270} catch (error) {
271console.error("Error fetching blob content:", error);
272} finally {
273setBlobContentLoading(false);
278const handleSave = async () => {
279try {
280await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
281method: "PUT",
282body: editContent,
290const handleDelete = async (key) => {
291try {
292await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
293setBlobs(blobs.filter(b => b.key !== key));
294if (selectedBlob && selectedBlob.key === key) {
307const key = `${searchPrefix}${file.name}`;
308formData.append("key", encodeKey(key));
309await fetch("/api/blob", { method: "POST", body: formData });
310const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
311setBlobs([newBlob, ...blobs]);
315}
316}
317fetchBlobs();
318};
319329try {
330const fullKey = `${searchPrefix}${key}`;
331await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
332method: "PUT",
333body: "",
344const handleDownload = async (key) => {
345try {
346const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
347const blob = await response.blob();
348const url = window.URL.createObjectURL(blob);
363if (newKey && newKey !== oldKey) {
364try {
365const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
366const content = await response.blob();
367await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
368method: "PUT",
369body: content,
370});
371await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
372setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
373if (selectedBlob && selectedBlob.key === oldKey) {
383const newKey = `__public/${key}`;
384try {
385const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
386const content = await response.blob();
387await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
388method: "PUT",
389body: content,
390});
391await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
392setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
393if (selectedBlob && selectedBlob.key === key) {
402const newKey = key.slice(9); // Remove "__public/" prefix
403try {
404const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
405const content = await response.blob();
406await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
407method: "PUT",
408body: content,
409});
410await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
411setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
412if (selectedBlob && selectedBlob.key === key) {
838});
839840export default lastlogin((request: Request) => app.fetch(request));
1112try {
13const response = await fetch("/messages", {
14method: "POST",
15headers: { "Content-Type": "application/json" },
reactHonoExampleApp.tsx4 matches
9const [messages, setMessages] = React.useState(initialMessages);
1011const fetchMessages = async () => {
12try {
13const response = await fetch("/messages");
14const data = await response.json();
15setMessages(data.reverse());
16} catch (error) {
17console.error("Failed to fetch messages", error);
18}
19};
23<h1>💬 Message Board</h1>
24<MessageList messages={messages} />
25<MessageInput onSubmit={fetchMessages} />
26{thisProjectURL
27? (
154155// Serve cached response if less than 1 minute old
156const imageResponse = await fetch(imageUrl);
157158if (imageResponse.ok) {
229230try {
231const response = await fetch(unsplashApiUrl, {
232headers: {
233"Accept-Version": "v1",
239// Include the response body for more detailed error information
240const errorBody = await response.text();
241return new Response(`Failed to fetch from Unsplash API: ${errorBody}`, { status: response.status });
242}
243247const imageUrl = `${photo.urls.raw}${additionalParams ? `&${additionalParams}` : ""}`;
248249// Fetch the specific image
250const imageResponse = await fetch(imageUrl);
251252if (!imageResponse.ok) {
hnTopStoriesmain.tsx2 matches
2526async function getTopHNStory() {
27const topStories = await fetch(
28"https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
29).then((res) => res.json());
30
31const id = topStories[0];
32const story = await fetch(
33`https://hacker-news.firebaseio.com/v0/item/${id}.json?print=pretty`
34).then((res) => res.json());
11e.preventDefault();
12try {
13const result = await fetch("/process", {
14method: "POST",
15body: JSON.stringify({ query })
1112try {
13const response = await fetch("/messages", {
14method: "POST",
15headers: { "Content-Type": "application/json" },
reactHonoExampleindex.ts2 matches
60});
6162// HTTP vals expect an exported "fetch handler"
63// This is how you "run the server" in Val Town with Hono
64export default app.fetch;
reactHonoExampleApp.tsx4 matches
9const [messages, setMessages] = React.useState(initialMessages);
1011const fetchMessages = async () => {
12try {
13const response = await fetch("/messages");
14const data = await response.json();
15setMessages(data.reverse());
16} catch (error) {
17console.error("Failed to fetch messages", error);
18}
19};
23<h1>💬 Message Board</h1>
24<MessageList messages={messages} />
25<MessageInput onSubmit={fetchMessages} />
26{thisProjectURL
27? (