API klici
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
function getLast() {
|
||||
const url = `http://localhost:3000/vnosi`;
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query: "*",
|
||||
limit: 4
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (!data.success) {
|
||||
console.error('API Error:', data.message);
|
||||
return;
|
||||
}
|
||||
|
||||
for (let entry of data.data) {
|
||||
let build = `
|
||||
<div class="entry-card">
|
||||
<h3 class="entry-title">${entry.kljuc}</h3>
|
||||
<p class="entry-definition">${entry.tip}</p>
|
||||
${entry.vsebina}
|
||||
<p class="entry-example">${entry.primer}</p>
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.getElementById("entry-container").innerHTML += build;
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
|
||||
getLast();
|
||||
Reference in New Issue
Block a user