+
= $viewDatas['entity']->getCustomTitle() ?>데이터 조회 설정
@@ -101,6 +105,7 @@
let trafficChart = null;
document.addEventListener('DOMContentLoaded', () => {
+ // DOM 로드 후 바로 차트를 불러옵니다.
fetchDataAndDrawChart();
});
@@ -109,7 +114,8 @@
// -----------------------------------------------------------
async function fetchAggregatedData(startDate, endDate) {
- const baseEndpoint = '= base_url("/admin/traffic/data/{$viewDatas['entity']->getPK()}") ?>'; // CI4 라우트로 지정된 기본 엔드포인트
+ // PHP 변수를 사용하여 엔드포인트 URL을 구성합니다.
+ const baseEndpoint = '= base_url("/admin/traffic/data/{$viewDatas['entity']->getPK()}") ?>';
// GET 요청을 위해 쿼리 파라미터를 생성합니다.
const params = new URLSearchParams({
@@ -117,7 +123,7 @@
endDate: endDate
});
- // 최종 엔드포인트 URL: /traffic/data?startDate=...&endDate=...
+ // 최종 엔드포인트 URL: /admin/traffic/data/{PK}?startDate=...&endDate=...
const endpoint = `${baseEndpoint}?${params.toString()}`;
const maxRetries = 3;
@@ -126,8 +132,7 @@
for (let i = 0; i < maxRetries; i++) {
try {
const response = await fetch(endpoint, {
- method: 'GET', // GET 방식으로 변경
- // GET 요청이므로 body는 포함하지 않습니다.
+ method: 'GET', // GET 방식으로 유지
});
const result = await response.json();