Siem-P/Squad-page-Siem

Je hebt comments in je Node-code waarmee de code is uitgelegd

Closed this issue · 1 comments

Je hebt comments in je Node-code waarmee de code is uitgelegd

Squad-page-Siem/index.js

Lines 20 to 41 in db7788c

const pageTitle = req.query.squad || "squat-c-2022";
const data = await fetchApi(squadUrl); // Fetch api data using the squadURL variable
data.pageTitle = pageTitle // Set pageTitle for the active button state
res.render("index", data);
});
app.set("port", process.env.PORT || 8000);
app.listen(app.get("port"), function () {
console.log(`Application started on http://localhost:${app.get("port")}`);
});
// Function for fetching the API
async function fetchApi(url) {
const data = await fetch(url)
.then((response) => response.json())
.catch((error) => error);
return data;
}

Added some comments for explaining Node