Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Productpagina #18

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .DS_Store
Binary file not shown.
59 changes: 59 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Express uit de nodemodules map
import express from "express";

const url = "https://api.vinimini.fdnd.nl/api/v1/producten"; // URL naar Json data
const url2 = 'https://api.vinimini.fdnd.nl/api/v1';

// Maak een nieuwe express app aan
const app = express();

// Stel in hoe we express gebruiken
app.set("view engine", "ejs");
app.set("views", "./views");

// Gebruik maken van de "public" map
app.use(express.static("public"));

// Maak een route voor de index
app.get("/product", (request, response) => {
let productenUrl = url;
fetchJson(productenUrl).then((data) => {
response.render("producten", data);
});
});

// Detail pagina
app.get("/detail", (request, response) => {
let id = request.query.detailId || "clerps05z09jm0aw3vccjq5un";
let detailUrl2 = url2 + "/product?id=" + id;
console.log(detailUrl2);
fetchJson(detailUrl2).then((data) => {
// console.log(data)
response.render("detail", data);
});
});

app.get('/proces', (request, response) => {
response.render('proces')
})

app.get('/agenda', function (req, res) {
res.render('agenda')
})

// Stel het poortnummer in en start express
app.set('port', process.env.PORT || 8000)
app.listen(app.get('port'), function () {
console.log(`Application started on http://localhost:${app.get('port')}`)
})

// Start express op, haal het ingestelde poortnummer op
app.listen(app.get("port"), function () {
// Toon een bericht in de console en geef het poortnummer door
console.log(`Application started on http://localhost:${app.get("port")}`);
});
async function fetchJson(url, payload = {}) {
return await fetch(url, payload)
.then((response) => response.json())
.catch((error) => error);
}
1 change: 1 addition & 0 deletions node_modules/.bin/ejs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/jake

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/node

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading