url not hardcoded
This commit is contained in:
@ -7,4 +7,10 @@
|
||||
<!-- Create a div where the graphs will take place -->
|
||||
<div id="graphs"></div>
|
||||
|
||||
<script src="http://127.0.0.1/app.js"></script>
|
||||
<!-- <script src="http://127.0.0.1/app.js"></script> -->
|
||||
<script>
|
||||
let currenturl = (window.location);
|
||||
var s = document.createElement( 'script' );
|
||||
s.setAttribute( 'src', `${currenturl}/app.js` );
|
||||
document.body.appendChild( s );
|
||||
</script>
|
||||
|
@ -11,6 +11,10 @@ const margin = {
|
||||
// get window width
|
||||
const width = window.innerWidth - margin.right - margin.left -10;
|
||||
|
||||
// url
|
||||
const currentUrl = window.location.href;
|
||||
console.log(currentUrl);
|
||||
|
||||
|
||||
// reload page when window is resized
|
||||
// (resizes every elements)
|
||||
@ -18,7 +22,7 @@ window.onresize = function(){ location.reload(); }
|
||||
|
||||
async function fetch_history() {
|
||||
try {
|
||||
const response = await fetch('http://127.0.0.1:8080/datahistory');
|
||||
const response = await fetch(`${currentUrl}/datahistory`);
|
||||
const rawData = await response.json();
|
||||
// SELECT uuid, quantity, discount_percentage, price, currency, h_timestamp
|
||||
let historyData = rawData.map(d => ({
|
||||
@ -37,7 +41,7 @@ async function fetch_history() {
|
||||
async function fetch_item() {
|
||||
try {
|
||||
// SELECT uuid, itemid, skuid, choice, attributes, image
|
||||
const response = await fetch('http://127.0.0.1:8080/dataitem');
|
||||
const response = await fetch(`${currentUrl}/dataitem`);
|
||||
const rawData = await response.json();
|
||||
const items = rawData.reduce((item, row) => {
|
||||
const uuid = row[0];
|
||||
|
Reference in New Issue
Block a user