specifičen vnos

This commit is contained in:
2026-04-23 11:44:55 +02:00
parent 474e07f6c5
commit de2c6749e5
8 changed files with 103 additions and 8 deletions

37
scripts/vnos.js Normal file
View File

@@ -0,0 +1,37 @@
const kljuc = new URLSearchParams(window.location.search).get("kljuc");
function getKey() {
const url = `http://localhost:3000/vnos`;
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
pk: kljuc
})
})
.then(response => response.json())
.then(data => {
if (!data.success) {
console.error('API Error:', data.message);
return;
}
let build = `
<h3 class="entry-title">${data.data.kljuc}</h3>
<p class="entry-definition">${data.data.tip}</p>
${data.data.vsebina}
<p class="entry-example">${data.data.primer}</p>
<p class="entry-example">Vnos dodal: ${data.data.avtor}</p>
`;
document.getElementById("page-title").innerText = `Vnos '${data.data.kljuc}'`;
document.getElementById("entry-container-single").innerHTML += build;
})
.catch((error) => {
console.error('Error:', error);
});
}
getKey();