Browse Source

On passe l'url du serveur au travers d'un entrypoint

Sangfroid 1 month ago
parent
commit
08216f8dcf
3 changed files with 7 additions and 1 deletions
  1. 2 0
      .gitignore
  2. 3 0
      entrypoint.js
  3. 2 1
      main.js

+ 2 - 0
.gitignore

@@ -22,3 +22,5 @@ dist-ssr
 *.njsproj
 *.sln
 *.sw?
+
+*.local.js

+ 3 - 0
entrypoint.js

@@ -0,0 +1,3 @@
+// Copier ce fichier en .entrypoint.local.js sur votre serveur
+
+export const entrypoint = "http://url-back-api-countdown/counter";

+ 2 - 1
main.js

@@ -1,6 +1,7 @@
 import './styles/counter.css'
 import { Countdown } from './counter.js'
 import { fetchObject } from './fetch.js';
+import { entrypoint } from './entrypoint.local.js';
 
 // select elements
 const main = document.querySelector('#app');
@@ -13,7 +14,7 @@ main.appendChild(heading);
 main.appendChild(app);
 main.appendChild(message);
 
-const api = new fetchObject("http://localhost:8000/counter", main.dataset.id);
+const api = new fetchObject(entrypoint, main.dataset.id);
 constcheckCounter();
 
 // Get the new year