Add a 'no jobs available' if not jobs in breezy.

This commit is contained in:
Thomas Smith 2023-05-04 14:44:34 +02:00
parent 353ac32766
commit 722cf08c35

View file

@ -27,11 +27,20 @@
</div>
</section>
<script>
<script>
// Fetch data from API
fetch("https://tea.breezy.hr/json?verbose=true")
.then(response => response.json())
.then(data => {
// Check if data is empty
if (data.length === 0) {
// Display message when no jobs are available
const container = document.getElementById("card-container");
const noJobsMessage = document.createElement("div");
noJobsMessage.classList.add("alert", "alert-info");
noJobsMessage.textContent = "No jobs available right now";
container.appendChild(noJobsMessage);
} else {
// Loop through data and create card for each item
data.forEach(item => {
// Create card element
@ -92,9 +101,10 @@
row.appendChild(col);
container.appendChild(row);
});
}
})
.catch(error => console.log(error));
</script>
</script>
<style>