// static/js/proxy.js export const proxyData = () => ({ proxies: [], }); export const proxyMethods = () => ({ async fetchProxies() { if (!this.isLoggedIn) { // Assuming isLoggedIn is available in the main app this.proxies = []; return; } const token = localStorage.getItem('access_token'); try { const response = await fetch('/api/proxies', { headers: { 'Authorization': `Bearer ${token}` } }); const data = await response.json(); if (response.ok) { this.proxies = data; console.log('Fetched proxies:', data); } else { console.error('Error fetching proxies:', data.detail); this.proxies = []; if (response.status === 401) { this.logout(); // Assuming logout is available in the main app } } } catch (error) { console.error('Error fetching proxies:', error); this.proxies = []; } } });