PageSourceSearch

https://www.com2us.com/dist/js/ajax.js

js com2us.com collected 2026-09-24 08:53:02 UTC 4,437 bytes, 155 lines download raw bytes

1const ajax = {
2  request(url, params = {}, options = {}) {
3    if (loadingBar) {
4      loadingBar.show(); // 로딩바 표시
5    }
6
7    const method = (options.method || "GET").toLowerCase();
8    const csrfToken = document
9      .querySelector('meta[name="_csrf"]')
10      ?.getAttribute("content");
11    const csrfHeader = document
12      .querySelector('meta[name="_csrf_header"]')
13      ?.getAttribute("content");
14
15    const headers = {
16      "Content-Type": "application/json;charset=UTF-8",
17      "X-Requested-With": "XMLHttpRequest",
18      "X-AJAX-REQUEST": "T",
19      ...options.headers,
20    };
21
22    if (csrfToken && csrfHeader) {
23      headers[csrfHeader] = csrfToken;
24    }
25
26    const axiosConfig = {
27      url,
28      method,
29      headers,
30    };
31
32    if (method === "get") {
33      // GET 요청 - URL에 쿼리스트링 추가
34      const queryString = new URLSearchParams(params).toString();
35      axiosConfig.url = queryString ? `${url}?${queryString}` : url;
36    } else if (
37      method === "post" &&
38      headers["Content-Type"] === "application/x-www-form-urlencoded"
39    ) {
40      // FORM 요청 - x-www-form-urlencoded 데이터 처리
41      const formData = new URLSearchParams(params).toString();
42      axiosConfig.data = formData;
43    } else if (
44      method === "post" &&
45      headers["Content-Type"] === "multipart/form-data"
46    ) {
47      // FILE 요청 - multipart/form-data 처리
48      axiosConfig.data = params; // FormData 객체 전달
49    } else {
50      // 기타 요청 - JSON 데이터 처리
51      axiosConfig.data = params;
52    }
53
54    return axios(axiosConfig)
55      .then((response) => response.data) // 응답 데이터를 반환
56      .catch((error) => {
57        //451 penta 에러 처리
58        if (error?.response?.status === 451 && error?.response?.data?.message) {
59          pentaError(error?.response?.data?.message);
60        } else if (error?.response?.status === 401) {
61          pentaAwaitAlert("인가되지 않은 요청입니다.").then((res) => {
62            top.location.href = "/admin/login";
63          });
64        } else if (error?.response?.status === 403) {
65          pentaAwaitAlert("인증되지 않은 요청입니다.").then((res) => {
66            top.location.href = "/admin/login";
67          });
68        } else {
69          // 에러 메시지가 존재한다면 출력
70          if (error?.response?.data?.message) {
71            // pentaError(error?.response.data.message); // 출력제거
72            pentaError(
73              "예기치 못한 오류가 발생했습니다.\n잠시 후 다시 시도해 주세요.",
74            );
75          } else {
76            let errorMessage = error.response
77              ? `HTTP Error: ${error.response.status}`
78              : "Network request failed.";
79            if (error?.message) {
80              errorMessage = errorMessage + " - " + error?.message;
81            }
82            // console.error(errorMessage);
83            // pentaError(errorMessage);
84            pentaError(
85              "예기치 못한 오류가 발생했습니다.\n잠시 후 다시 시도해 주세요.",
86            );
87          }
88        }
89
90        throw error;
91      })
92      .finally(() => {
93        if (loadingBar) {
94          loadingBar.hide(); // 로딩바 숨김
95        }
96      });
97  },
98
99  // GET 요청
100  get(url, params = {}, headers = {}) {
101    return this.request(url, params, {
102      method: "GET",
103      headers,
104    });
105  },
106
107  // POST 요청
108  post(url, params = {}, headers = {}) {
109    return this.request(url, params, {
110      method: "POST",
111      headers,
112    });
113  },
114
115  // PUT 요청
116  put(url, params = {}, headers = {}) {
117    return this.request(url, params, {
118      method: "PUT",
119      headers,
120    });
121  },
122
123  // DELETE 요청
124  delete(url, params = {}, headers = {}) {
125    return this.request(url, params, {
126      method: "DELETE",
127      headers,
128    });
129  },
130
131  // FORM 요청 (x-www-form-urlencoded)
132  form(url, params = {}, headers = {}) {
133    const formHeaders = {
134      ...headers,
135      "Content-Type": "application/x-www-form-urlencoded",
136    };
137    return this.request(url, params, {
138      method: "POST",
139      headers: formHeaders,
140    });
141  },
142
143  // MULTIPART 요청
144  multipart(url, formData, headers = {}) {
145    const formHeaders = {
146      ...headers,
147      "Content-Type": "multipart/form-data",
148    };
149
150    return this.request(url, formData, {
151      method: "POST",
152      headers: formHeaders,
153    });
154  },
155};

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.