PageSourceSearch

https://www.co-op.crs/CoopCRSThemeStatic/themes/CoopCRSTheme/js/cu…2d35f87ad97fbae474985b9813d72dcfba4d-82-ver

js co-op.crs collected 2026-10-02 13:07:38 UTC 4,781 bytes, 152 lines download raw bytes

1var HTTPHelper = (typeof HTTPHelper == "undefined" || !HTTPHelper) ? {} : HTTPHelper;
2
3function getEnv() {
4    let host = window.location.host.split('.')[0];
5    if (host === 'www' || host == 'authoring') {
6        return 'https://www.digitalservices.crs';
7    } else if (host === 'uat' || host === 'uat-authoring') {
8        //return 'https://cdpapi-test.azurewebsites.net';
9        return 'https://uat.digitalservices.crs';
10    } else if (host === 'test') {
11        return 'https://test.digitalservices.crs';
12    } else if (host === 'dev') {
13        return 'https://dev.digitalservices.crs';
14    }
15}
16
17function useDuplicateMicroservice(url){
18    //return modifiedUrl = url.replace(/\/(gl-customerservice|gl-membershipservice|gl-loyaltyservice|gl-careservice)(?=\/)/, '/$12');
19    return modifiedUrl = url.replace(/\/(gl-customerservice|gl-membershipservice|gl-loyaltyservice)(?=\/)/, '/$12');
20}
21//const basehost = 'http://localhost:8080';
22const basehost = getEnv();
23const baseHeaders = {
24    'Content-Type': 'application/json',
25}
26
27function isDuplicateMicroserviceNeeded() {
28    return window.location.host.split('.')[0] === 'uat' || window.location.host.split('.')[0] === 'uat-authoring';
29    //return window.location.host.split('.')[0] === 'uat-authoring';
30}
31
32// HTTPHelper.testUser = function (sub = sessionData.sub, token = sessionData.token) {
33//     let url = '/api/web/v2/customer/' + sub;
34//     let headers = {
35//         'Content-Type': 'application/json',
36//         'Authorization': 'Bearer ' + token
37//     };
38//     return axios({
39//         method: 'get',
40//         url: `${host}${url}`,
41//         headers: headers
42//     })
43//         .then(response => {
44//             return response;
45//         })
46//         .catch(error => {
47//             console.log(error)
48//         })
49// };
50
51HTTPHelper.callApi = async (method, url, withToken = false, data = null, host = basehost, headers = baseHeaders) => {
52    if (url.charAt(0) !== '/'){
53        url = '/' + url;
54    }
55    
56    if (isDuplicateMicroserviceNeeded()){
57        url = useDuplicateMicroservice(url);
58    }
59    
60    var isJson = headers['Content-Type'] && headers['Content-Type'] == 'application/json';
61    if (withToken) {
62        let token = JSON.parse(FCLCookies.getCookie('cooptoken')).token;
63        headers['Authorization'] = 'Bearer ' + token;
64    }
65    if (method == 'GET') {
66        return axios(
67            {
68                url: `${host}${url}`,
69                method: method,
70                params: data,
71                headers: headers
72            })
73            .then(response => {
74                return response;
75            })
76            .catch(error => {
77                throw error
78            })
79    } else if (method == 'POST') {
80        return axios({
81            url: url,
82            method: method,
83            baseURL: host,
84            data: isJson ? data : qs.stringify(data),
85            headers: headers
86        })
87            .then(response => {
88                return response;
89            })
90            .catch(error => {
91                throw error
92            })
93    } else if (method == 'PUT'){
94        return axios({
95            url: url,
96            method: method,
97            baseURL: host,
98            data: isJson ? data : qs.stringify(data),
99            headers: headers
100        })
101            .then(response => {
102                return response;
103            })
104            .catch(error => {
105                throw error
106            })
107    } else if (method == 'PATCH' || method == 'DELETE') {
108        return axios({
109            url: url,
110            method: method,
111            baseURL: host,
112            data: data,
113            headers: headers
114        })
115            .then(response => response)
116            .catch(error => {
117                throw error
118            })
119    }
120}
121
122HTTPHelper.getEquityPDFs = async (method, url, withToken = false, data = null, host = basehost, headers = baseHeaders) => {
123    if (url.charAt(0) !== '/'){
124        url = '/' + url;
125    }
126    
127    if (isDuplicateMicroserviceNeeded()){
128        url = useDuplicateMicroservice(url);
129    }
130
131    var isJson = headers['Content-Type'] && headers['Content-Type'] == 'application/json';
132    if (withToken) {
133        let token = JSON.parse(FCLCookies.getCookie('cooptoken')).token;
134        headers['Authorization'] = 'Bearer ' + token;
135    }
136    if (method == 'GET') {
137        return axios(
138            {
139                url: `${host}${url}`,
140                method: method,
141                params: data,
142                headers: headers,
143                responseType: 'arraybuffer'
144            })
145            .then(response => {                
146                return response;
147            })
148            .catch(error => {                
149                throw error
150            })
151    }
152}

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.