mirror of
https://github.com/Daniongithub/ER-TPL.git
synced 2025-12-06 11:02:02 +00:00
Notizie seta!!!
This commit is contained in:
29
seta_modena/menu/js/notizia.js
Normal file
29
seta_modena/menu/js/notizia.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const link = params.get('link');
|
||||
const notiziaContainer = document.getElementById('notizia-container');
|
||||
|
||||
//URL
|
||||
const newsURL = "https://setaapi.serverissimo.freeddns.org/news?link="+link;
|
||||
|
||||
notiziaContainer.innerHTML="<p>Caricamento notizia...</p>";
|
||||
fetch(newsURL)
|
||||
.then(response => {
|
||||
if (!response.ok){
|
||||
notiziaContainer.innerHTML="<p>Impossibile raggiungere l'API.</p>";
|
||||
throw new Error("Errore nel caricamento dei dati.");
|
||||
}
|
||||
return response.json();
|
||||
}).then(element =>{
|
||||
notiziaContainer.innerHTML="";
|
||||
var div = document.createElement('div');
|
||||
var h1 = document.createElement('h1');
|
||||
var p = document.createElement('p');
|
||||
var p2 = document.createElement('p');
|
||||
p.innerHTML=element.date;
|
||||
h1.innerHTML=element.title;
|
||||
div.appendChild(p);
|
||||
div.appendChild(h1);
|
||||
p2.innerHTML=element.content;
|
||||
div.appendChild(p2);
|
||||
notiziaContainer.appendChild(div);
|
||||
})
|
||||
Reference in New Issue
Block a user