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) {
826});
827828export default lastlogin((request: Request) => app.fetch(request));
weatherGPTmain.tsx1 match
4let location = "brooklyn ny";
5let lang = "en";
6const weather = await fetch(
7`https://wttr.in/${location}?lang=${lang}&format=j1`,
8).then(r => r.json());
130return c.json(await getRows())
131} catch (error) {
132console.error("Error fetching data:", error)
133return c.text("Error fetching data", 500)
134}
135})
170`)
171172return app.fetch(req)
173}
121const [moveDirection, setMoveDirection] = useState(null);
122const [hasInteracted, setHasInteracted] = useState(false);
123const fetchedRecords = useRef(new Set());
124125useEffect(() => {
126async function fetchReleases() {
127try {
128const response = await fetch("https://ashryanio-getallreleasesfromdiscogs.web.val.run");
129if (!response.ok) {
130throw new Error(`HTTP error! status: ${response.status}`);
131}
132const fetchedRecords = await response.json();
133if (!Array.isArray(fetchedRecords)) {
134throw new Error("Received data is not an array");
135}
136137const shuffledRecords = shuffleArray(fetchedRecords);
138setRecords(shuffledRecords);
139setIsLoading(false);
140} catch (error) {
141console.error("Failed to fetch releases:", error);
142setError(error.message);
143setIsLoading(false);
144}
145}
146fetchReleases();
147}, []);
148149// Fetch release year for the current record
150useEffect(() => {
151async function fetchReleaseYear() {
152if (records.length === 0) return;
153154const currentRecord = records[currentRecordIndex];
155if (!currentRecord || fetchedRecords.current.has(currentRecord.basic_information.master_id)) {
156return; // Skip if already fetched
157}
158159try {
160console.log("Fetching release year for:", currentRecord);
161const response = await fetch(
162`https://ashryanio-getallreleasesfromdiscogs.web.val.run/masters?id=${currentRecord.basic_information.master_id}`,
163);
164if (!response.ok) {
165throw new Error(`Failed to fetch release year: ${response.status}`);
166}
167const data = await response.json();
168console.log("Fetched data:", data);
169170// Mark as fetched
171fetchedRecords.current.add(currentRecord.basic_information.master_id);
172173// Update the record
180);
181} catch (error) {
182console.error("Error fetching release year:", error);
183}
184}
185186fetchReleaseYear();
187}, [currentRecordIndex, records.length]);
188
cerebras_codermain.tsx4 matches
3637useEffect(() => {
38async function fetchStats() {
39const response = await fetch("/dashboard-stats");
40const data = await response.json();
41setStats(data);
42}
43fetchStats();
44}, []);
45146147try {
148const response = await fetch("/", {
149method: "POST",
150body: JSON.stringify({
FetchBasicREADME.md2 matches
1# Framer Fetch: Basic
23A basic example of an API endpoint to use with Framer Fetch. CORS headers are permissive by default on Val Town, so no need to set them.
53const imageApiEndpoint = record?.["rdf:RDF"]?.["svcs:Service"]?.[0]?.$?.["rdf:about"];
54if (imageApiEndpoint) {
55return fetch(imageApiEndpoint)
56.then(resp => resp.json())
57.catch((err) => console.log(`Error fetching Image Information from ${imageApiEndpoint}`, err));
58} else return null;
59}
62const uri = part.$["rdf:resource"];
63const id = uri.split("/").pop();
64return fetchJson(id)
65.then(getImageInformation)
66.catch((err) => console.log(`Error fetching more images from ${id}`, err));
67}
68142}
143144async function fetchJson(id: string) {
145const headers = new Headers([
146["Accept-Profile", "edm"],
149const url = new URL(apiBase + id);
150const parser = new Parser();
151return fetch(url, { headers })
152.then(resp => resp.text())
153.then(text => parser.parseStringPromise(text))
164});
165}
166const resp = await fetchJson(id.toString());
167if (resp.error || params.get("format") === "edm") {
168return Response.json(resp);
inspiringLavenderTakinmain.tsx4 matches
3637useEffect(() => {
38async function fetchStats() {
39const response = await fetch("/dashboard-stats");
40const data = await response.json();
41setStats(data);
42}
43fetchStats();
44}, []);
45146147try {
148const response = await fetch("/", {
149method: "POST",
150body: JSON.stringify({
slackScoutmain.tsx8 matches
20for (const topic of KEYWORDS) {
21const results = await Promise.allSettled([
22fetchHackerNewsResults(topic),
23fetchTwitterResults(topic),
24fetchRedditResults(topic),
25]);
2649}
5051// Fetch Hacker news, Twitter, and Reddit results
52async function fetchHackerNewsResults(topic: string): Promise<Website[]> {
53return hackerNewsSearch({
54query: topic,
58}
5960async function fetchTwitterResults(topic: string): Promise<Website[]> {
61return twitterSearch({
62query: topic,
67}
6869async function fetchRedditResults(topic: string): Promise<Website[]> {
70return redditSearch({ query: topic });
71}
84}
8586const response = await fetch(slackWebhookUrl, {
87method: "POST",
88headers: { "Content-Type": "application/json" },
interview_practicemain.tsx1 match
9091try {
92const response = await fetch("/ask", {
93method: "POST",
94headers: {