specifičen vnos
This commit is contained in:
37
scripts/vnos.js
Normal file
37
scripts/vnos.js
Normal 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();
|
||||
Reference in New Issue
Block a user