10e.preventDefault();
11try {
12const response = await fetch("/login", {
13method: "POST",
14headers: { "Content-Type": "application/json" },
58const [tagInput, setTagInput] = useState("");
5960// Fetch previous customer details when email changes
61useEffect(() => {
62const fetchCustomerDetails = async () => {
63if (!email) return;
6465try {
66const response = await fetch(`/get-customer-details?email=${encodeURIComponent(email)}`);
67if (response.ok) {
68const customerDetails = await response.json();
73}
74} catch (error) {
75console.error("Error fetching customer details:", error);
76}
77};
7879fetchCustomerDetails();
80}, [email]);
81138e.preventDefault();
139try {
140const response = await fetch("/add-interaction", {
141method: "POST",
142headers: { "Content-Type": "application/json" },
250const [uniqueCustomerCount, setUniqueCustomerCount] = useState(0);
251252const fetchUniqueCustomerCount = async () => {
253try {
254const response = await fetch("/get-unique-customer-count");
255const data = await response.json();
256setUniqueCustomerCount(data.count);
257} catch (error) {
258console.error("Error fetching unique customer count:", error);
259}
260};
261262useEffect(() => {
263fetchInteractions();
264fetchUniqueCustomerCount();
265}, [currentPage, selectedTags]);
266281const handleDeleteInteraction = async (id) => {
282try {
283const response = await fetch("/delete-interaction", {
284method: "DELETE",
285headers: { "Content-Type": "application/json" },
288289if (response.ok) {
290fetchInteractions();
291}
292} catch (error) {
303};
304305const fetchInteractions = async () => {
306try {
307const response = await fetch(`/get-interactions?page=${currentPage}`);
308const data = await response.json();
309336if (selectedTags.length > 0) {
337// Need to get total count of filtered interactions from server
338const filteredCountResponse = await fetch(`/get-filtered-count?tags=${selectedTags.join(",")}`);
339const filteredCountData = await filteredCountResponse.json();
340setTotalInteractions(filteredCountData.count);
343}
344} catch (error) {
345console.error("Error fetching interactions:", error);
346}
347};
348349useEffect(() => {
350fetchInteractions();
351}, [currentPage, selectedTags]);
352481const checkAuth = async () => {
482try {
483const response = await fetch("/check-auth");
484const data = await response.json();
485setIsAuthenticated(data.authenticated);
4041useEffect(() => {
42fetchTasks();
43loadUserPreferences();
44}, []);
72}
7374async function fetchTasks() {
75try {
76const response = await fetch("/get-tasks");
77const data = await response.json();
78setTaskLists(data);
79} catch (error) {
80console.error("Error fetching tasks", error);
81}
82}
8687try {
88const response = await fetch("/add-task", {
89method: "POST",
90headers: { "Content-Type": "application/json" },
107108try {
109const response = await fetch("/move-task", {
110method: "POST",
111headers: { "Content-Type": "application/json" },
125async function removeTask(taskId, column) {
126try {
127const response = await fetch("/delete-task", {
128method: "POST",
129headers: { "Content-Type": "application/json" },
142143try {
144const response = await fetch("/move-task", {
145method: "POST",
146headers: { "Content-Type": "application/json" },
174if (!editedTaskText.trim() || !taskBeingEdited) return;
175try {
176const response = await fetch("/update-task", {
177method: "POST",
178headers: { "Content-Type": "application/json" },
fetchEventsmain.tsx4 matches
1920try {
21// Fetch events from Luma API
22const response = await fetch(apiUrl, {
23method: "GET",
24headers: apiHeaders, // Use correct API headers here
40} catch (error) {
41// Log the error and return a 500 error response
42console.error("Error fetching events:", error);
43return new Response(
44JSON.stringify({ error: "Failed to fetch events", details: error.message }),
45{ status: 500, headers },
46);
terrificCoralMolemain.tsx3 matches
1export async function fetchEvents() {
2const url = "https://api.lu.ma/public/v1/calendar/list-events";
3const headers = {
78try {
9const response = await fetch(url, { method: "GET", headers });
10const data = await response.json();
11return data; // Return the API response
12} catch (error) {
13return { error: "Failed to fetch events", details: error.message };
14}
15}
136async function submitScore() {
137try {
138const response = await fetch("/submit-highscore", {
139method: "POST",
140headers: {
sweetBlackHaremain.tsx1 match
249250try {
251const response = await fetch('/analyze', {
252method: 'POST',
253body: formData
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));
cerebras_codermain.tsx1 match
182183try {
184const response = await fetch("/", {
185method: "POST",
186body: JSON.stringify({
tasks_test1main.tsx13 matches
162163React.useEffect(() => {
164fetchTasks();
165}, []);
166167const fetchTasks = async () => {
168const response = await fetch('/api/tasks');
169const fetchedTasks = await response.json();
170setTasks(fetchedTasks);
171};
172188if (newTask.text.trim() && newTask.dueDate) {
189try {
190const response = await fetch('/api/tasks', {
191method: 'POST',
192headers: { 'Content-Type': 'application/json' },
196setNewTask({ text: '', done: false, dueDate: DEFAULT_DATE });
197setIsAddTaskModalOpen(false);
198fetchTasks();
199}
200} catch (error) {
206const handleDeleteTask = async (taskId) => {
207try {
208const response = await fetch(`/api/tasks/${taskId}`, { method: 'DELETE' });
209if (response.ok) {
210fetchTasks();
211}
212} catch (error) {
224if (taskToEdit.text.trim() && taskToEdit.dueDate) {
225try {
226const response = await fetch(`/api/tasks/${taskToEdit.id}`, {
227method: 'PUT',
228headers: { 'Content-Type': 'application/json' },
232setIsEditTaskModalOpen(false);
233setTaskToEdit(null);
234fetchTasks();
235}
236} catch (error) {
242const handleToggleTaskCompletion = async (taskId, done) => {
243try {
244const response = await fetch(`/api/tasks/${taskId}`, {
245method: 'PATCH',
246headers: { 'Content-Type': 'application/json' },
248});
249if (response.ok) {
250fetchTasks();
251}
252} catch (error) {
helpfulTealTapirmain.tsx1 match
182183try {
184const response = await fetch("/", {
185method: "POST",
186body: JSON.stringify({