PageSourceSearch

https://town-country-market.com/wp-content/themes/svt/js/homesomeAPI.js?ver=1791092785

js town-country-market.com collected 2026-10-04 05:47:37 UTC 2,595 bytes, 85 lines download raw bytes

1class HomesomeAPI {
2    constructor(baseURL, apiKey) {
3        this.baseURL = baseURL;
4        this.apiKey = apiKey;
5    }
6
7    async request(endpoint, method = 'GET', body = null, headers = {}) {
8        if (!headers.apikey) {
9            headers.apikey = this.apiKey;
10        }
11
12        const forterToken = getCookie?.('forterToken');
13        if (forterToken) {
14            headers.forterToken = forterToken;
15        }
16
17        if (body) {
18            headers['Content-Type'] = 'application/json';
19        }
20
21        const options = {
22            method,
23            headers,
24        };
25
26        if (body) {
27            options.body = JSON.stringify(body);
28        }
29
30        try {
31            const response = await fetch(`${this.baseURL}${endpoint}`, options);
32            const contentType = response.headers.get('content-type') || '';
33            const text = await response.text();
34
35            if(response.status == 401) {
36                logoutUser();
37                window.location.href = sitedata.home_url;
38                return { error: true, message: 'Unauthorized', status: 401 };
39            }
40
41            if(response.status == 403) {
42                clearLocationData();
43                logoutUser();
44                window.location.href = sitedata.home_url;
45            }
46
47            if (!response.ok) {
48                if (endpoint.includes('birdzi/coupons')) {
49                    try {
50                        return JSON.parse(text);
51                    } catch {
52                        return text;
53                    }
54                } else {
55                    throw new Error(`API request failed with status: ${response.status}`);
56                }
57            }
58
59            try {
60                return contentType.includes('application/json') ? JSON.parse(text) : text;
61            } catch {
62                return text;
63            }
64        } catch (error) {
65            console.error('API Error:', error);
66            throw error;
67        }
68    }
69
70    async getData(endpoint, extraHeaders = {}) {
71        return this.request(endpoint, 'GET', null, extraHeaders);
72    }
73
74    async postData(endpoint, data, extraHeaders = {}) {
75        return this.request(endpoint, 'POST', data, extraHeaders);
76    }
77
78    async deleteData(endpoint, data = {}, extraHeaders = {}) {
79        return this.request(endpoint, 'DELETE', data, extraHeaders);
80    }
81
82    async putData(endpoint, data = {}, extraHeaders = {}) {
83        return this.request(endpoint, 'PUT', data, extraHeaders);
84    }
85}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.