37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
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(); |