From ae4f3bd9a7f752af891d8a00d40e63c13fb0b02a Mon Sep 17 00:00:00 2001 From: osaajani <> Date: Tue, 22 Oct 2024 14:31:06 +0200 Subject: [PATCH] Fix static url in query for advanced stats --- templates/stat/sms-status.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/templates/stat/sms-status.php b/templates/stat/sms-status.php index cde22e4..fcff7dc 100644 --- a/templates/stat/sms-status.php +++ b/templates/stat/sms-status.php @@ -81,9 +81,15 @@ const formatedEndDate = endDate.toISOString().split('T')[0] const id_phone = document.getElementById('id_phone').value; - let url = `http://127.0.0.1/raspisms/api/stats/sms-status?api_key=a25cc40e2ffcc661170e28dc56724f67&start=${formatedStartDate}&end=${formatedEndDate}`; - url = (id_phone ? `${url}&id_phone=${id_phone}` : url ); - const response = await fetch(url); + const query_infos = \descartes\Router::url('Api', 'get_sms_status_stats'), 'api_key' => $_SESSION['user']['api_key']])?>; + + let url = `${query_infos.url}?start=${formatedStartDate}&end=${formatedEndDate}`; + url += id_phone ? `&id_phone=${id_phone}` : ''; + const response = await fetch(url, { + headers: { + 'X-Api-Key': query_infos.api_key + } + }); const data = (await response.json()).response; // Get all dates to avoid holes in data