File size: 1,134 Bytes
133609a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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 = [];
        }
    }
});